I have a local script inside of StarterCharacterScripts, and it only works if the player doesn't die. Any suggestions?
Here is my code:
--do variables local Player = game:GetService("Players").LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() repeat wait() until Character:FindFirstChild("Humanoid") local humanoid = Character.Humanoid local Mouse = Player:GetMouse() local debounce = false local anim = workspace["Cyborg SP1"] local playAnim = humanoid:LoadAnimation(anim) local player = game.Players.LocalPlayer local ReplicatedStorage = game:GetService("ReplicatedStorage") local event = ReplicatedStorage:WaitForChild("Cyborg SP1") --make an animation play when button is pressed Mouse.KeyDown:connect(function(key) if debounce == false then if key == "1" then print("test") debounce = true playAnim:Play() script.Parent.Parent.Humanoid.WalkSpeed = 0 event:FireServer() wait(0.7) script.Parent.Parent.Humanoid.WalkSpeed = 16 wait(1.3) debounce = false end end end) --fire server for projectiles and stuff
Also, I am not sure if this is important or not, but this script is placed inside of a model in StarterCharacterScripts.