for some reason, my tool is duplicated many times and I want to prevent that, does anyone know about this? please help me.
Script:
local price = 1200
local db = true
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.leaderstats.Cash.Value >= price then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - price
db = false
game.Lighting["1# Feathers Texture BB"]:clone().Parent = player.Backpack
wait(2)
db = true
end
end)
Because you are cloning the tool each time player Click.
Try this:
local price = 1200
local db = true
local ToClone = game.Lighting["1# Feathers Texture BB"]:Clone()
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.leaderstats.Cash.Value >= price then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - price
db = false
ToClone.Parent = player.Backpack
wait(2)
db = true
end
end)
And also to prevent it to be bought again edit it like this:
local price = 1200
local db = true
local ToClone = game.Lighting["1# Feathers Texture BB"]:Clone()
script.Parent.ClickDetector.MouseClick:Connect(function(player)
if player.leaderstats.Cash.Value >= price and not player.Backpack:FindFirstChild(["1# Feathers Texture BB"]) then
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - price
db = false
ToClone.Parent = player.Backpack
wait(2)
db = true
end
end)
local Lighting = game:GetService("Lighting")
local Tool = Lighting:WaitForChild("1# Feathers Textures BB")
local DB = false
local Click = script.Parent
Click.MouseClick:Connect(function(Player)
if Player.leaderstats.Cash.Value >= price and not Player.Backpack:FindFirstChild("1# Feathers Textures BB") and not DB then
DB = true
Player.leaderstats.Cash.Value -= price
Tool:Clone().Parent = Player.Backpack
wait(2)
DB = false
end
end)