Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i cooldown my script on spawning a car from ServerStorage?

I am trying to make a cooldown on a script but it just doesnt work. I tried some stuff but it doesnt work

value = workspace.Spawner.Screen.Spawn.Frame.TextButton.Value
text = workspace.Spawner.Screen.Spawn.Frame.TextLabel

if value.Value == 1 then 
text.Text = Cooldown
wait (1)
text.Text = Drive Safely
else
		script.Parent.MouseButton1Click:connect(function(GetCar) ---Start of script
		Mod = game.ServerStorage.Camaro
		clone = Mod:clone()
		clone.Parent = workspace
		clone:MakeJoints() ---End of script
		value.Value == 1
		wait (5)
		value.Value == 0
end)

7 comments

0

^ How about actually trying to help him instead of downvoting.

0

How about he help us so we can help him, by providing error details. Upvotes are only for good posts, you upvoted him for no reason...

0

Plus that link explains why i -1

0

I never upvoted him :)

0

There is so much wrong in this example. value.Value being checked outside of the click handler, assignments being attempted with == instead of =, text strings that aren't in quotes, mouse click handler having an argument called GetCar (why?) etc. This code won't even run as-is.

0

@programmerHere actually where does it say it is only for good posts?

1 answer

✓ Accepted answer

There's tons of errors that occurred while you were trying to make your script, here's a script that should work. Indentation is also, important.

local value = workspace.Spawner.Screen.Spawn.Frame.TextButton.Value
local text = workspace.Spawner.Screen.Spawn.Frame.TextLabel
local deb = false -- debounce to make the cooldown

script.Parent.MouseButton1Click:Connect(function() -- event to continuously run the if check
	if value.Value == 1 then -- checking if the value == 1
		text.Text = "Cooldown" -- quotations represent its a message
		wait(1)
		text.Text = "Drive Safely" -- quoatations
	else
		if not deb then
			deb = true
			local mod = game.ServerStorage.Camaro
			clone.Parent = workspace
			clone:MakeJoints()
			if value.Value == 1 then -- if statement check
				value.Value = 0
			end
			wait(1)
			deb = false
		end
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.