-
What do you want to achieve? I was doing a system when player dies it plays a animation depending of what player was holding (W or S key)
-
What is the issue? It works only when I’m idling, only one animation plays, i get damaged 100% fourth times (fatality kill lol), and it collides with ground and goes up then breaksjoints
-
What solutions have you tried so far? i looked other posts it didnt help
local script in StarterCharacterScripts (plz help because i can’t continue with my game)
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local localPlayer = Players.LocalPlayer
local character = localPlayer.Character or localPlayer.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.BreakJointsOnDeath = false
local playerFolder = script:WaitForChild("Player")
local deathAnimFolder = playerFolder:WaitForChild("Death")
local runningAnimFolder = playerFolder:WaitForChild("Running")
local animations = {
Run = runningAnimFolder:WaitForChild("RunAnim"),
BackDeath = deathAnimFolder:WaitForChild("BackDeath"), -- falling back triggers when holding S or down arrow while walking or running
FrontDeath = deathAnimFolder:WaitForChild("FrontDeath"), -- falling in front triggers when holding W or up arrow while walking or running
}
local animationTracks = {}
humanoid.HealthChanged:Connect(function(health)
if health <= 0 then
stopAllAnimations()
local movementDirection = humanoid.MoveDirection
local deathAnimationName
local deathDuration
if movementDirection.Z < 0 then
deathAnimationName = "FrontDeath"
deathDuration = animations["FrontDeath"].Duration.Value
else
deathAnimationName = "BackDeath"
deathDuration = animations["BackDeath"].Duration.Value
end
playAnimation(deathAnimationName)
task.delay(deathDuration, function()
humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)
humanoid:TakeDamage(humanoid.MaxHealth)
end)
end
end)