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

Gives 10 swords instead of one. Help?

Asked by
Proflts 15
9 years ago

I am trying to make a brick give people a linked sword and when people fall through it (cancollide is false) it gives them 10 instead of one, here is the code. Please help.

1script.Parent.Touched:connect(function()
2    for i, v in pairs(game.Players:GetChildren()) do
3        if v.Backpack ~= nil
4            then
5            clone = game.Lighting.LinkedSword:Clone()
6            clone.Parent = v.Backpack
7        end
8    end
9end)

1 answer

Log in to vote
1
Answered by 9 years ago
01script.Parent.Touched:connect(function()
02    for i, v in pairs(game.Players:GetChildren()) do
03        if v.Backpack ~= nil
04            then
05if v.Backpack:FindFirstChild("LinkedSword") == nil then --will make sure its not in the bag first
06            clone = game.Lighting.LinkedSword:Clone()
07            clone.Parent = v.Backpack
08end
09        end
10    end
11end)
0
thank you bro much appreciated Proflts 15 — 9y
Ad

Answer this question