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