local part = game.Workspace.Part LinkedSword = game.Lighting.LinkedSword while true do for i,v in pairs(game.Players:GetChildren()) do if (v.Character.Torso.Position - part.Position).magnitude <= 15 then c = game.Lighting.LinkedSword:clone() c.Parent = v.Backpack break end end wait() end
Whenever I get near the object, I clone the swords into my backpack infinitely. How do I do it so that it'll only clone into my backpack once.
I don't know if this will fix it, but since you have already defined "Linked sword" up top you can use your variable down lower.
c = LinkedSword:clone
Before you give them a tool, make sure they don't already own it.
local part = game.Workspace.Part LinkedSword = game.Lighting.LinkedSword while true do for i,v in pairs(game.Players:GetChildren()) do if (v.Character.Torso.Position - part.Position).magnitude <= 15 then if(not v.Backpack:FindFirstChild("LinkedSword")) then --If they don't own it c = game.Lighting.LinkedSword:clone() c.Parent = v.Backpack end end end wait() end