Alright, the example that I had here was very poor, let me give another…
https://gyazo.com/ca63830b67e65ba0260ddff9d5470b79
In this one I am running a for loop with making all of these parts and sending them to random locations. If one gets touched, it will then damage the player…
for i=1, NumberOfParts do
local part = Instance.new("Part", workspace)
game:GetService("Debris"):AddItem(part, 2)
part.Name = "LeafEffect"
part.BrickColor = BrickColor.new("Grime")
part.CanCollide = false
part.Anchored = true
part.Size = Vector3.new(1,.2,1)
part.TopSurface = Enum.SurfaceType.Smooth
part.BottomSurface = Enum.SurfaceType.Smooth
part.Transparency = 1
part.Position = position
part.CFrame = CFrame.new(position, part.Position + Vector3.new(math.random(-10,10),3, math.random(-10,10)))
table.insert(AllParts, part)
local LeafImage = script.Parent.Leaf:Clone()
LeafImage.Parent = part
LeafImage.Enabled = true
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not hit:IsDescendantOf(script.Parent.Parent) then
hit.Parent.Humanoid:TakeDamage(DAMAGE)
local gui = Instance.new("BillboardGui", hit.Parent.Head)
gui.Size = UDim2.new(10,0,2,0)
gui.StudsOffset = Vector3.new(0,3,0)
local Label = Instance.new("TextLabel", gui)
Label.Size = UDim2.new(1,0,1,0)
Label.BackgroundTransparency = 1
Label.TextColor3 = Color3.new(255,0,0)
Label.TextStrokeTransparency = 0
Label.Text = DAMAGE
Label.TextScaled = true
game:GetService("Debris"):AddItem(gui, .5)
plr.XP.Value = plr.XP.Value + XPPerKill
part:Destroy()
end
end
end)
end
So right now I have the number of parts shooting out at 50. Meaning if there is a 25 player server and everyone is spamming this tool, it would be looking at that loop 1250 times in a matter of seconds…
So what most of you said about the PlayerAdded event was very true, it is not anything to worry about. It was solely for a example of what I am talking about.