So, I'm currently working on opening a door but it isnt working. So yes it does open the doors but it doesnt close..
Heres my script
local openfrontdoors = script.Parent local key = game.ReplicatedStorage.getKey:InvokeServer("getkey") local checkdoor = game.ReplicatedStorage.checkdoor:InvokeServer("status",key) openfrontdoors.MouseButton1Click:connect(function() if checkdoor == false then print(checkdoor) game.ReplicatedStorage.OpenDoors:FireServer("closefrontdoor",script.Parent.Parent.Parent,key) elseif checkdoor == true then print(checkdoor) game.ReplicatedStorage.OpenDoors:FireServer("openfrontdoor",script.Parent.Parent.Parent,key) end end)
local openfrontdoors = script.Parent openfrontdoors.MouseButton1Click:connect(function() local key = game.ReplicatedStorage.getKey:InvokeServer("getkey") local checkdoor = game.ReplicatedStorage.checkdoor:InvokeServer("status",key) if checkdoor == false then print(checkdoor) game.ReplicatedStorage.OpenDoors:FireServer("closefrontdoor",script.Parent.Parent.Parent,key) elseif checkdoor == true then print(checkdoor) game.ReplicatedStorage.OpenDoors:FireServer("openfrontdoor",script.Parent.Parent.Parent,key) end end)
This should work. You weren't redefining key
and checkdoor
every time you clicked so it was always the same value and it never changed. So this new version of the script redefines it every time you click so that the value is always updated.
Up vote and Accept if this helped
Try this
local openfrontdoors = script.Parent local key = game.ReplicatedStorage.getKey:InvokeServer("getkey") local checkdoor = game.ReplicatedStorage.checkdoor:InvokeServer("status",key)
openfrontdoors.MouseButton1Click:connect(function() if checkdoor == false then print(checkdoor) game.ReplicatedStorage.OpenDoors:FireServer("closefrontdoor",script.Parent.Parent.Parent,key) else if checkdoor == true then print(checkdoor) game.ReplicatedStorage.OpenDoors:FireServer("openfrontdoor",script.Parent.Parent.Parent,key) end end end)