kills = game.Workspace.LeaderboardV3.leaderstats.KOs
script.Parent.ClickDetector.MouseClick:connect(function(Buy)
if kills >= 0 then
for i,v in pairs(game.Players:GetChildren()) do
if v.Backpack ~= nil then
clone2 = game.Lighting.Venomshank:Clone()
clone2.Parent = v.Backpack
end
end
end
end)
COMMUNITY QUESTION
Can someone tell me whats wrong? It wont spawn the venomshank in my backpack.
1 answer
This is what you did wrong: in the first line you defined kills as the leaderstat in the player. So you are basically saying that if the leaderstat kills = 0 then you get it. You get the sword. You want to define the value. So then you will be saying if the player has 0 kills then buy the sword.
kills = game.Workspace.LeaderboardV3.leaderstats.KOs.Value
So this would be the script:
kills = game.Workspace.LeaderboardV3.leaderstats.KOs.Value
script.Parent.ClickDetector.MouseClick:connect(function(Buy)
if kills >= 0 then
for i,v in pairs(game.Players:GetChildren()) do
if v.Backpack ~= nil then
clone2 = game.Lighting.Venomshank:Clone()
clone2.Parent = v.Backpack
end
end
end
end)
1 comment
0
whenever i click it it says leaderstats is invalid value or something like that
This discussion is preserved as it was. New answers, comments, and votes are closed.

3 comments
Line 4, maybe. | if kills.Value >=0 then | Also, on line 6, use v:FIndFirstChild("Backpack") to check if the Backpack instead.
thanks bro
it didnt work