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

script.Parent.Touched:connect(function()
    for i, v in pairs(game.Players:GetChildren()) do
        if v.Backpack ~= nil 
            then
            clone = game.Lighting.LinkedSword:Clone()
            clone.Parent = v.Backpack
        end
    end
end)

1 answer

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

Answer this question