Hello.
I made this script :
And i would like to know how to find a way that when the player press the button he can’t press it again (Because of the game idea) (The game will contain 1 player per server)
I’m not asking for script !!! Just a way to do it
I’d advise providing a code snippet in text form rather than screenshot.
Add a variable to check if they’ve already used it, like this:
local usedButton = false
if usedButton == false then
-- button has been clicked
usedButton = true
end
2 Likes
quamatic
(Quam)
March 31, 2020, 4:16pm
#3
One of the most simple ways is just to have a variable to declare if clicked. Once they click, check if has been clicked and stop the process, otherwise move on.
2 Likes
local soundbutton = script.Parent
function startscenary(player)
local Fun = player.PlayerGui.HaveFuntext
print("Button has been clicked !")
wait(2)
Fun.Enabled = true
wait(3)
Fun.Enabled = false
wait(1)
game.Workspace.Neons.Neon1.Material = ("SmoothPlastic")
game.Workspace.Neons.Neon2.Material = ("SmoothPlastic")
game.Workspace.Neons.Neon3.Material = ("SmoothPlastic")
game.Workspace.Neons.Neon4.Material = ("SmoothPlastic")
game.Workspace.Neons.Neon5.Material = ("SmoothPlastic")
game.Workspace.Neons.Neon6.Material = ("SmoothPlastic")
game.Workspace.NeonLights.NeonLight1.SpotLight.Brightness = 0.1
game.Workspace.NeonLights.NeonLight2.SpotLight.Brightness = 0.1
game.Workspace.NeonLights.NeonLight3.SpotLight.Brightness = 0.1
game.Workspace.NeonLights.NeonLight4.SpotLight.Brightness = 0.1
game.Workspace.NeonLights.NeonLight5.SpotLight.Brightness = 0.1
game.Workspace.NeonLights.NeonLight6.SpotLight.Brightness = 0.1
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("Neon")
game.Workspace.RedLightsMaterial.Light2.Material = ("Neon")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 14
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 14
wait(0.5)
game.Workspace.RedLightsMaterial.Light1.Material = ("SmoothPlastic")
game.Workspace.RedLightsMaterial.Light2.Material = ("SmoothPlastic")
game.Workspace.RedLightsLight.RedLight1.Light.Brightness = 0
game.Workspace.RedLightsLight.RedLight2.Light.Brightness = 0
wait(0.5)
game.Workspace.Neons.Neon1.Material = ("Neon")
game.Workspace.Neons.Neon2.Material = ("Neon")
game.Workspace.Neons.Neon3.Material = ("Neon")
game.Workspace.Neons.Neon4.Material = ("Neon")
game.Workspace.Neons.Neon5.Material = ("Neon")
game.Workspace.Neons.Neon6.Material = ("Neon")
game.Workspace.NeonLights.NeonLight1.SpotLight.Brightness = 1.3
game.Workspace.NeonLights.NeonLight2.SpotLight.Brightness = 1.3
game.Workspace.NeonLights.NeonLight3.SpotLight.Brightness = 1.3
game.Workspace.NeonLights.NeonLight4.SpotLight.Brightness = 1.3
game.Workspace.NeonLights.NeonLight5.SpotLight.Brightness = 1.3
game.Workspace.NeonLights.NeonLight6.SpotLight.Brightness = 1.3
end
soundbutton.MouseClick:Connect(startscenary)
Here’s the script. I understand that i have to put the deconnect code into the button part ?
I’m not sur if i have to put the code into the part button or past the entire code that i have done into the deconnect code ?