Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gives 10 swords instead of one. Help?

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

✓ Accepted answer
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)

1 comment

0

thank you bro much appreciated

This discussion is preserved as it was. New answers, comments, and votes are closed.