I made this script in order to spawn an object when a button is pressed and that part works, but the problem is when I tried to make a cool-down. Now, it is just always showing as ready = 1 and never 0 so there is no cool-down. Why?
local ready = script.Parent.Parent.Ready.Value
local Spawner = Vector3.new(157.326, 8.715, 26.577)
local Clicker = script.Parent
local Object = game.ReplicatedStorage:WaitForChild("Cardboard")
local ObjectSpawn = script.Parent.Parent.Spawn
local ready = 1
if ready == 1 then
Clicker.MouseClick:Connect(function()
ready = 0
local CloneObject = Object:Clone()
CloneObject.Parent = game.Workspace
CloneObject:MoveTo(Spawner)
wait (12)
end )
ready = 1
end
if ready == 0 then
script.Parent.Parent.BrickColor=BrickColor.new("Bright red")
print("ready = 0")
else
print ("Ready = 1")
end

1 comment
Add a debounce