Animations from local script not working after player dies

  1. What do you want to achieve?
    I want to make it so the animation works after the player respawns

  2. What is the issue?
    I have an equip torch script which adds the torch model via a script in serverscriptservice and plays the animations through a local script.
    the problem is that after the player dies, the animations don’t work anymore.
    what it should look like:


    what it looks like after respawning:

  3. What solutions have you tried so far?
    i’ve looked on devforum and the only solution that i’ve thought of is to move the animation and humanoid finding variables(?) inside the function instead so it looks for the humanoid each time the function is fired. however this didn’t work as the animations weren’t stopping and were just overlapping instead

local Service = game:GetService("UserInputService")
local players = game:GetService("Players").LocalPlayer

local par = script.Parent
local debounce = false

local animlibaray = game.ReplicatedStorage.Libraries.Animations.Torch
local char = players.Character or players.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")

local equipanim = hum.Animator:LoadAnimation(animlibaray.TorchEquipAnim)
local equipidle = hum.Animator:LoadAnimation(animlibaray.TorchEquippedAnim)
local unequipanim = hum.Animator:LoadAnimation(animlibaray.TorchUnEquipAnim)


function torchequip()

	if debounce == false then
		debounce = true
		game.ReplicatedStorage.Events:WaitForChild("TorchEquipEvent"):FireServer(false)
		equipanim:Play()
		wait(0.8)
		equipidle:Play()
		equipanim:Stop()
		
		
	else
		debounce = false
		game.ReplicatedStorage.Events:WaitForChild("TorchEquipEvent"):FireServer(true)
		equipidle:Stop()
		unequipanim:Play()
		
	end
end

---------------------------------------

Service.InputBegan:Connect(function(KeyboardInput)
	if KeyboardInput.KeyCode.Name == "F" then
		torchequip()
		wait(1)
	end
end)

script.Parent.MouseButton1Click:Connect(function()
	torchequip()
	wait(1)
end)

help would be greatly appreciated

You need to load the animations for the Animator everytime the player spawns

1 Like

do u have any idea how i could do something like that??

try to turn off this option in the humanoid:

BreaksJointOnDeath

Where is this script parented?

under a gui button since its activated via button press or key press

this still breaks the joints if i disable it in play mode?

Well see here:

local equipanim = hum.Animator:LoadAnimation(animlibaray.TorchEquipAnim)
local equipidle = hum.Animator:LoadAnimation(animlibaray.TorchEquippedAnim)
local unequipanim = hum.Animator:LoadAnimation(animlibaray.TorchUnEquipAnim)

This is where you load the animations for the Humanoid, now what we need to do is reload the animation, so my question is simple, for your gui that this is parented to, is ResetOnDeath enabled?

i have resetondeath disabled for the gui that its parented to

Ok enable it, it should solve the problem

1 Like

yes, this does work but i don’t want other things in my gui to reset after spawn
is there a workaround for that

That is most likely cause you did not turn it off in the server, and turned it off on the client. Try to turn it off on the server first

2 Likes

Remove the current logic for waiting until the character is added and have a permanent

player.CharacterAdded:Connect(function(character)
local animator = character:WaitForChild("Humanoid"):WaitForChild("Animator")
equipanim = animator:LoadAnimation(animlibaray.TorchEquipAnim)
equipidle = animator:LoadAnimation(animlibaray.TorchEquippedAnim)
unequipanim = animator:LoadAnimation(animlibaray.TorchUnEquipAnim)
end)

ty for the help! this didnt work but i do appreciate the help

thank youu its working now! i appreciate the help

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.