Hello, just a heads up that I am very very new to scripting, and this is my first time trying to script something.
I am basically trying to create a keypad that opens a door when the correct code is entered. I tried following a tutorial on YT by SteelKidGaming, but I can’t seem to make it work for me.
Here is what I did:
- Each button has a script, click detector, surfacegui, and a text label.
- The script I used (from the tutorial), minus the clicking sound he used
db = false
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if db == false then
db = true
script.Parent.Position = script.Parent.Position - Vector3.new(0.2,0,0)
script.Parent.Parent.CodeShower.SurfaceGui.TextLabel.Text = script.Parent.Parent.CodeShower.SurfaceGui.TextLabel.Text…script.Parent.Name
wait(0,1)
script.Parent.Position = script.Parent.Position + Vector3.new(0.2,0,0)
wait(0,1)
db = false
end
end
From my understanding, the script.Parent.Position = script.Parent.Position part basically makes the button retract when pressed, but when I tested it, the part does not retract. Does this have something to do with the part being anchored?
And then the script.Parent.Parent.CodeShower.SurfaceGui.TextLabel.Text = script.Parent.Parent.CodeShower.SurfaceGui.TextLabel.Text…script.Parent.Name part should be displaying the button pressed. I made sure to rename the parts like the CodeShower, too.
Inside the CodeShower part, I only have a surfaceGui and an empty text label, as per the tutorial.
The buttons seem to be unpressable as the buttons don’t retract at all when I test it, and it doesn’t even display the text on the CodeShower.
Thank you.