In a local script do:
(animations do replicate to server in local scripts)
Make sure animation is already an instance you made.
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local animator = humanoid:WaitForChild("Animator")
local animation = script:WaitForChild("DeathAnim")
local track = animator:LoadAnimation(animation)
humanoid.Died:Connect(function()
track:Play()
humanoidRootPart.Anchored = true
end)
since when the player dies the animation makes the player move around on the ground
also am planning of making an orb go around the player for respawning effect so freezing the player in the air would be ideal for that
Managed to get it working using this solution and some serverside code
Local:
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local humanoidRootPart = char:WaitForChild("HumanoidRootPart")
local animator = humanoid:WaitForChild("Animator")
local animation = script:WaitForChild("DeathAnim")
local track = animator:LoadAnimation(animation)
local replicatedstorage = game:GetService("ReplicatedStorage")
local deathevent = replicatedstorage:WaitForChild("PlayerDeath")
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
deathevent:FireServer(player)
track:Play()
task.wait(track.Length - 1.30)
print("Animation Paused")
track:AdjustSpeed(0)
end)
Serverside
local replicatedstorage = game:GetService("ReplicatedStorage")
local deathevent = replicatedstorage:WaitForChild("PlayerDeath")
deathevent.OnServerEvent:Connect(function(player)
print("Event Found!")
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local humanoidRootPart = char:WaitForChild("HumanoidRootPart")
humanoidRootPart.Anchored = true
wait(5) -- Wait Timer
player:LoadCharacter()
end)
i have tried many times and it seems to not be freezing
(even if it did the player can now load instead of being stuck)