The script is a script in a weapon that is supposed to deal damage to a player. It's not working, and I don't know why. Output didn't give me anything. Can someone please help me?
Here's the script:
on=true function onhit(hit) if not on then return end on=false local Dmg=105 local humanoid = hit.Parent:findFirstChild("Humanoid") local player = game.Players:findFirstChild(hit.Parent.Name) if humanoid ~= nil then if player and player.TeamColor ~= script.Parent.creator.Value.TeamColor then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - Dmg script.Parent.Anchored=true script.Parent.CanCollide=false script.Parent.Anchored=true script.Parent.CanCollide=false script.Parent.Throw.Looped=false script.Parent.Throw.Volume=0 wait(2) script.Parent:Destroy() end end script.Parent.Anchored=true script.Parent.CanCollide=false script.Parent.Throw.Looped=false script.Parent.Throw.Volume=0 script.Parent.Throw:stop() wait(2) script.Parent:Destroy() end script.Parent.Touched:connect(onhit)
Try keeping CanCollide to true. Maybe the Touched event doesn't fire when CanCollide is false?