So, I was making a damage script for my game. When you attack, it creates an StringValue called "Attacking", then the touched event connects, while you have this stringvalue, you will attack the opponent. But for some reason, I was creating a barrage move. When I test it on a Dummy, the attack froze the game (in roblox studio), increase ping by ALOT (in Roblox player, can increase ping to over 25k ms. This is a server script, whenever a tool wants to damage, It will fire this script. It also gives no errors or anything.
local event = game.ReplicatedStorage.Damage
local stunhit = false
local hitt = 0
event.OnServerEvent:Connect(function(player, partdmg, dmg, attacktime, cd, soundid, soundvolume)
if cd == 0 then return end
local chr = player.Character
if cmd == "normalattack" then
local candamage = Instance.new("StringValue")
candamage.Name = "Attacking"
candamage.Parent = chr
candamage.Value = "NotHit"
game.Debris:AddItem(candamage, attacktime)
partdmg.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and chr:FindFirstChild("Attacking").Value == "NotHit" then
if hitt == 1 then return end
hitt = 1
hit.Parent.Humanoid:TakeDamage(dmg)
candamage.Value = "IsHit"
local sound = Instance.new("Sound")
sound.Volume = soundvolume
sound.Name = "hitsound"
sound.MinDistance = 1
sound.MaxDistance = 20
sound.SoundId = soundid
sound.Parent = hit.Parent.Torso
sound:Play()
game.Debris:AddItem(sound, 5)
wait(cd)
hitt = 0
end
return
end)
end
end)

2 comments
This doesn't look harmful or have any loops that could crash your Studio. Is there anything else?
I think this was because of the script having too much work to do. As you see, every 0.2 seconds, the script will delete the value, create the value, delete the value, create the value for 3 - 5 seconds