Here's my script. It works fine until I added if debounce == false then A working script or tell me how to fix this?
local player = game.Players.LocalPlayer
local weapons = script.Parent.Parent:WaitForChild("weapons"):GetChildren()
local spinTime = 1
local numberOfSpins = 1
local debounce = false
script.Parent.MouseButton1Click:connect(function()
if debounce == false then
if player.leaderstats.BUX.Value >= 300 then
player.leaderstats.BUX.Value = player.leaderstats.BUX.Value - 300
script.Parent.Parent.State.Text = "Spinning..."
script.Parent.Parent.State.Visible = true
print("Starting")
debounce = true
local finalWeapon = weapons[math.random(1, #weapons)]
for i = 1, numberOfSpins do
if i == numberOfSpins then
for _,v in pairs(weapons) do
v.Visible = false
end
finalWeapon.Visible = true
print("Finished")
script.Parent.Parent.State.Text = "You got: " .. finalWeapon.Name
break
end
local thisWeapon = weapons[math.random(1, #weapons)]
thisWeapon.Visible = true
wait(spinTime / numberOfSpins)
thisWeapon.Visible = false
end
end
debounce = false
end
end)
