Broken multiplayer door script

I am making a multiplayer door, so multiple people have to be on the buttons. _2P and _1P are those button values that make everything run.
But my door script does not work. The script looks like this:

if (script.Parent.Parent._1P.Value == true) and (script.Parent.Parent._2P.Value == true) then
print(“Both players there!”)
script.Parent.Transparency = 1
script.Parent.CanCollide = false
end

I have tried switching it to a while - do loop, checked the values and they work, so everything except this works. Please help.

the “then” is on the second row for whatever reason, it’s not like that in studio

1 Like

Well, are you firing it?

Placing code inside a script with no event or loop running it means that it will run once and never again.
So, you either use a while true do, as you said, or connect it to an event, like a ClickDetector.

If you want your script to show up properly so others can read it, just type 3 backwards single quotes before and after the script when you paste it in here

I have never had issues with this in the past, but I will see if it works. I have never put my if-thens in while-dos before and it always works.

Well, without a loop or event it literally checks if the values are true at the start of the game (or when the script first runs if it’s disabled at first) and that’s it.

Placing code inside a script with no event or loop running it means that it will run once and never again.

Still does not work. I put it in a while-do loop and it does not work or fire still.

Well then it means one or both values are not being set to true.

Well then it means one or both values are not being set to true.

This is also not true, as I checked and both values are true.

Here’s proof:
robloxapp-20210110-1534468.wmv (1.2 MB)

The doors shut whenever a button is pressed. The box is there because i have no friends.

I have found a workaround, but this issue is still not fully resolved. My workaround was to have the second player’s door open when the first player presses his button, so both are required, but this may be exploitable.