This script works but is there a better/easier way of scripting this?
- This script just clones a part to each character in the game and welds it to their own torso.
while wait() do
local Part = game.ReplicatedStorage:WaitForChild('Cop')
local plrs = game.Players:GetPlayers()
for i = 1, #plrs do
local Char = plrs[i].Character
local Torso = Char.Torso
if not Torso:FindFirstChild('Cop') then
local clonedPart = Part:Clone()
clonedPart.Parent = Torso
local Weld = Instance.new('Weld', Torso)
Weld.Part0 = Torso
Weld.Part1 = clonedPart
Weld.C0 = CFrame.new(0,0,0)
end
end
end

2 comments
The code is fine man. Efficiency wise it can't be improved much more. I guess if anything I would suggest using a generic for to iterate through your table, rather than a numerical. But it's completely your preference and your way works just fine.
Is the an example of what the for loop you are talking about looks like?