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

How Can I Make The Script That Purchase An Item One Time Only Without Spamming?

Asked by
ImfaoXD 158
8 years ago

What I want to do is to make the script that make player purchase item one time only instead of spamming. How can I do that? Can anyone help me?

local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
local price = 1 
local tool = game.Lighting:findFirstChild("Teleport") 

function picture() 
script.Parent.Parent.Picture.Image = "http://www.roblox.com/asset/?id=51067285" 
script.Parent.Parent.Price.Text = "$1" 
end 

function buy()
wait(0.1)
local money = player.leaderstats.KOs
if money.Value >= price then 
local a = tool:clone() 
a.Parent = player.Backpack
else 
end 
end 




script.Parent.MouseButton1Down:connect(buy) 
script.Parent.MouseEnter:connect(picture)

1 answer

Log in to vote
0
Answered by
Vezious 310 Moderation Voter
8 years ago

First Of All, If This Is A Local Script, change the Player Variable. If It's not a local script, which it should be, then Ignore what I have to say. Second Of All, Try using debounce, BUT instead of changing it to its original value, keep it the same.

local player = game.Players.LocalPlayer
local price = 1 
local debounce = false
local tool = game.Lighting:findFirstChild("Teleport") 

function picture() 
script.Parent.Parent.Picture.Image = "http://www.roblox.com/asset/?id=51067285" 
script.Parent.Parent.Price.Text = "$1" 
end 

function buy()
if debounce == false then
debounce = true
wait(0.1)
local money = player.leaderstats.KOs
if money.Value >= price then 
local a = tool:clone() 
a.Parent = player.Backpack
else 
end 
end 




script.Parent.MouseButton1Down:connect(buy) 
script.Parent.MouseEnter:connect(picture)

You also can remove the script. But I'd choose Debounce method instead.

0
It's doesn't work,what should I do? D: ImfaoXD 158 — 8y
0
And yes, this is a normal script. ImfaoXD 158 — 8y
0
Oh great, the D in the Debounce Variable was uppercase, I changed it. Should work now. If not, then, either its a server script, else your original script doesn't work. Vezious 310 — 8y
Ad

Answer this question