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

How would I make a ship spawner that will take away Coins when clicked?

Asked by 3 years ago
Edited 3 years ago

I am trying to make a ship spawner but I want it to take away Coins when clicked here is my script:

~~~~~~~~~~~~~~~~~

local Coins = game.Players:WaitForChild("leaderstats.Coins")

local ServerStorage = game:GetService("ServerStorage")

local detector = workspace["Regen Speedboat 50 Coins"] local debounce = false script.Parent.ClickDetector.MouseClick:Connect(function() if debounce then return end debounce = true print("I was clicked!") local Copy = ServerStorage:FindFirstChild("SpeedBoat"):Clone() Copy.Parent = workspace Copy.Name = "Speedone" Copy:MoveTo(Vector3.new(-14, 2.5, -344)) wait(6) debounce = false end)

~~~~~~~~~~~~~~~~~

1 answer

Log in to vote
0
Answered by
MemezyDev 172
3 years ago
Edited 3 years ago

This should work. If this does please accept my answer as the solution :)

01local ServerStorage = game:GetService("ServerStorage")
02 
03local detector = workspace["Regen Speedboat 50 Coins"]
04local debounce = false
05 
06local SHIP_COST = 50--Coins cost
07 
08script.Parent.ClickDetector.MouseClick:Connect(function(player)
09    if debounce then
10        return
11    end
12    debounce = true
13    print("I was clicked!")
14 
15    local coins = player.leaderstats.Coins
View all 27 lines...
Ad

Answer this question