Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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)
0
^ How about actually trying to help him instead of downvoting. Tyler090130 619 — 4y
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... programmerHere 371 — 4y
0
Plus that link explains why i -1 programmerHere 371 — 4y
View all comments (3 more)
0
I never upvoted him :) Tyler090130 619 — 4y
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. EmilyBendsSpace 1025 — 4y
0
@programmerHere actually where does it say it is only for good posts? ZorbaTheGreatGreek 59 — 4y

1 answer

Log in to vote
0
Answered by
0_2k 496 Moderation Voter
4 years ago
Edited 4 years ago

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)
Ad

Answer this question