Hello, I want to make a boolvalue that determines what happens when a player hits a button
However, when attempting this, I came to the problem where the player would step on the button and I think it instantly triggered a change and I don’t really know how to fix it.
I tried adding debounce, but it did not seem to work and I have searched around, but could not find anything that helped me with this specific problem
Here’s my code, if anyone could help I would really appreciate it!
Debounce = false
Teleporter = script.Parent
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local CDKind = player.CDs.LabWelcome
if player and Debounce == false and CDKind.Value == false then
Debounce = true
player.PlayerGui.CDGet.Frame.TextLabel.Text = "CD Get! - Welcome to the lab!"
player.PlayerGui.CDGet.Frame.Visible = true
player.CDs.LabWelcome.Value = true
script.Parent.Collect:Play()
wait(3)
player.PlayerGui.CDGet.Frame.Visible = false
Debounce = false
else if CDKind.Value == true then
Debounce = true
player.PlayerGui.CDGet.Frame.Visible = true
player.PlayerGui.CDGet.Frame.TextLabel.Text = "Already Collected! - Welcome to the lab!"
script.Parent.Collect:Play()
wait(3)
player.PlayerGui.CDGet.Frame.Visible = false
Debounce = false
end
end
end
connection = Teleporter.Touched:connect(onTouched)
