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

How to delay A mouse button 1 click function?

Asked by 5 years ago
Edited 5 years ago

I've already tried putting wait functions. It's pretty self explanatory.

script.Parent.MouseButton1Click:Connect(function()

    script.Parent.Text = "Please Wait."
    wait(0.2)
    script.Parent.Text = "Please Wait.."
    wait(0.2)
    script.Parent.Text = "Please Wait..."
    wait(0.2)


    if game.Players.LocalPlayer.Jeep.Value == true then
        script.Parent.Text = "Spawn"
        game.ReplicatedStorage.SpawnCar:FireServer(script.Parent.Parent.Name)
        script.Parent.Parent.Parent.Visible = false

    else

        -- Let them purchase it

        local PriceOfItem = game.ReplicatedStorage:WaitForChild("CheckPrice"):InvokeServer(script.Parent.Parent.Name)

        if game.Players.LocalPlayer.leaderstats.Cash.Value >= PriceOfItem and script.Parent.Parent.Purchased.Value == false then
            -- The player has enough cash
            game.Players.LocalPlayer.leaderstats.Cash.Value = game.Players.LocalPlayer.leaderstats.Cash.Value - PriceOfItem
            script.Parent.Parent.Purchased.Value = true
            game.Players.LocalPlayer.Jeep.Value = true
            script.Parent.Text = "Spawn"

            script.Parent.Parent.Parent.Visible = false
        end
    end
    end)
0
1. explain further, i dont understand. 2. post the script fanofpixels 718 — 5y
0
added Car00071 11 — 5y
0
Add a bool value and use if statements awesomeipod 607 — 5y
0
This is alvinbloxx’s code again. User#19524 175 — 5y
View all comments (2 more)
0
Alvinblox lmao awesomeipod 607 — 5y
0
^ This question breaks the "Attempts should be of own work" rule. User#19524 175 — 5y

1 answer

Log in to vote
0
Answered by
Macbane 46
5 years ago
Edited 5 years ago

Use a debounce this is what a debounce looks like

debounce = true
script.Parent.MouseButton1Click:Connect(function()
    if debounce then 
        debounce = false
        wait(1)
        --script here
        debounce = true
    end
end)

more info on debounces here http://wiki.roblox.com/index.php?title=Scripting_Book/Chapter_6

Ad

Answer this question