Reputation: 1
I am in ROBLOX studio (the newest version) and my code isn't working.
The LocalScript is parented to a part with a ProximityPrompt.
Although there are no errors, nor warnings, it cannot open or close the door.
The code is below this line.
door = script.Parent
isOpen = false
function openDoor()
door.Transparency = 1
door.CanCollide = false
isOpen = true
end
function closeDoor()
door.Transparency = 0
door.CanCollide = true
isOpen = false
end
function main()
if isOpen then
openDoor()
else
closeDoor()
end
end
door.ProximityPrompt.Triggered:Connect(main)
closeDoor()
Upvotes: 0
Views: 78
Reputation: 7188
According to the docs for LocalScripts :
A LocalScript will only run Lua code if it is a descendant of one of the following objects:
- A Player’s Backpack, such as a child of a Tool
- A Player’s character model
- A Player’s PlayerGui
- A Player’s PlayerScripts.
- The ReplicatedFirst service
So, unless it's important that this code only run on a single client, just swap the code over to a server Script.
Upvotes: 0