So I am trying to make a little button on GUI which will open or close door of the house but there’s a problem, the following script does not acknowledge existence of my boolValue even if I use WaitForChild
game.ReplicatedStorage.HouseDoorEvent.OnServerEvent:connect(function(player)
if player.house.Value == 'house1' then
if player.doorIsClosed.Value == false then
game.Workspace.house1Rent.Parent = game.ServerStorage
player:WaitForChild("doorIsClosed")
player.doorIsClosed = true
else
game.ServerStorage.house1rent.Parent = game.Workspace
player:WaitForChild("doorIsClosed")
player.doorIsClosed = false
end
end
end)
The error is: doorIsClosed is not a valid member of Player "Players.Lemon553311"
so you can try adding :WaitForChild() and :FindFirstChild()
game.ReplicatedStorage.HouseDoorEvent.OnServerEvent:connect(function(player)
if player:WaitForChild("house").Value == 'house1' then
if player:WaitForChild("doorIsClosed").Value == false then
game.Workspace.house1Rent.Parent = game.ServerStorage
player:WaitForChild("doorIsClosed")
player.doorIsClosed = true
else
game.ServerStorage.house1rent.Parent = game.Workspace
player:WaitForChild("doorIsClosed")
player.doorIsClosed = false
end
end
end)