Number value not changing

Hello, I have been working on a game similar to Doors and other similar games. When making a chase sequence I wanted the door behind the player to close when the player ended the chase.

Here is some things about the doors in my game.

  • The doors are controlled by a module script that is always called by the server
  • The doors can be opened and closed by changing the number value named “open”
  • To close the door the “open” value must be 0

This system works fine with other rooms in my game except the chase ending. The number value changes for other rooms but doesn’t with the chase ending. Instead the value will stay the same.

Here is the code I used for BOTH the chase and other rooms.

-- used for other rooms
GeneratedRooms[EnterCount - 1]:FindFirstChild("Door"):FindFirstChild("open").Value = 0
-- used for chase ending (practically the same)
GeneratedRooms[EnterCount - 2]:FindFirstChild("Door"):FindFirstChild("open").Value = 0

This is the code that runs once the chase ends.

    game.Lighting.ExposureCompensation = -2
    GeneratedRooms[EnterCount - 1]:FindFirstChild("Door"):FindFirstChild("open").Value = 0
	monster:Destroy()
	SoundHandler.ChangeSettings("Chase", nil, nil, 109)
	remoteEvents.PlayerData:FireAllClients(16)

All of this runs perfectly with no errors but the number value in the door does not change.

I suspect there is something interfering with the values but I am not sure. I would really appreciate some explanation. (btw I wrote this really late so I’m sorry if it sound kinda unclear)

Well, at the end of the day, as your script shows, you’re not calling the action that actually moves the door, you’re just changing a fake value.

Could you explain how your system works?

The system that I use will do the open and closing action automatically. But I have tested and have concluded that the door closing and opening system is not a cause of the problem. The value simply does not change.

This is a video of me opening and closing the door by manually changing the value in the door.

As you can see the door works fine. But on my chase sequence the script somehow fails to change the value to 0. How ever using the same method it works on other rooms. I think it’s because of another thing interfering with the script.

Nevermind, I found the problem. After testing I forgot that functions don’t update parameters which values were changed. I also stupidly didn’t use a breakpoint in other tests. I forgot to mention that they were in a function.

I simply added 1 to “EnterCount” everytime the player opened a new room during the chase.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.