I am currently working on a game that includes a sword script. I made a localscript for the actual mechanisms of the tool. Here's my localscript.
local Cooldown = true local RandomPos = math.random(0,1) local Player = game.Players.LocalPlayer local Char = Player.Character or Player.CharacterAdded:wait() local Hum = Char:WaitForChild('Humanoid') local Anim = Hum:LoadAnimation(script.Parent.Animation) local leaderstats = Player:WaitForChild("leaderstats") script.Parent.Activated:Connect(function() if Cooldown == true then Cooldown = false script.Parent.Handle.sword_swing1:Play() leaderstats.Yen.Value = leaderstats.Yen.Value + script.Parent.Interval.Value local AddCashAlert = Player.PlayerGui.CashRecievedGui.Frame.TextLabel AddCashAlert.Text = "+"..script.Parent.Interval.Value Anim:Play() AddCashAlert.TextTransparency = 0 script.Parent.Handle.Trail.Enabled = true for i = 0,1,.1 do AddCashAlert.TextTransparency = i wait() end wait(.7) Cooldown = true script.Parent.Handle.Trail.Enabled = false end end) script.Parent.Unequipped:Connect(function() Anim:Stop() script.Parent.Handle.PutIn:Play() end) script.Parent.Equipped:Connect(function() script.Parent.Handle.PutOut:Play() end)
But however, when the player dies from an NPC or dies from reseting, the script doesn't work anymore. No animations, no trails, nothing. Could anyone help and give me a thorough explaination for this? Thanks.
P.S, Sorry for the formatting. I don't know how to fix that issue, so if you know the answer, please comment on this post.