Hi, i have a Door Code script that works, i just need function when players enter the correct code, the door stay open only for them.
The door work perfectly, i just need a localscript for avoid player doesn't have code to cross the door in the same time of player have code ^^
The code:
Code = "9796" --change To any numbers You like
Input = ""
--This Is for my buddy siros
--created by
------------------------------------------
--Clear And Enter
function Clear()
print("Cleared")
Input = ""
end
script.Parent.Clear.ClickDetector.MouseClick:connect(Clear)
function Enter()
if Input == Code then
print("Entered")
Input = ""
local door = script.Parent.Parent.Door
door.CanCollide = false
wait(3)
door.CanCollide = true
return end
Input = ""
print("Wrong Code")
end
script.Parent.Enter.ClickDetector.MouseClick:connect(Enter)
under this script i have this function for button
function Click0()
Input = Input..0
print("0")
script.Parent.B0.Decal.Texture = "http://www.roblox.com/asset/?id=2767674"
wait(0.1)
script.Parent.B0.Decal.Texture = "http://www.roblox.com/asset/?id=2761903"
end
script.Parent.B0.ClickDetector.MouseClick:connect(Click0)
I have this for B0,B1,B2 etc.. for number 1 to 9

6 comments
So you want the door to open only for the person that entered the code and not anyone else?
You should not use deprecated code like :connect. Also please indent your code properly when programming it makes it easier to read and understand as well as debug.
Yes Vezious
You can just put the local script in starterplayerscripts. You can put the serverscript wherever you want it as long as you have a variable for the door and the player that entered the code. You can even use the server sided script in the script you already have.
it is all up to you.
For the love of god use local variables. Usage of global variables is a bad practice because they make code messy, and in conjunction with poorly indented code even messier. Global variables also pollute the global namespace, and can increase risks for name collisions. It's best to avoid any conflict.