So, I’m not sure if this is a bug, but I made a script where stuff is supposed to happen when player dies. Every descendant of the character must be anchored when player dies. I tried to do that by doing this:
Humanoid.Died:Connect(function()
for i, v in pairs(Character:GetDescendants()) do
if v:IsA("Part") or v:IsA("UnionOperation") or v:IsA("MeshPart") then
v.Anchored = true
end
end
end)
I mean it does what i ask for, but it doesn’t do it in real time.
Then I found BreakJointsOnDeath
.
I set it to false, but now Humanoid.Died
won’t fire until the player is moved.
Here’s a video of what I’m experiencing:
https://gyazo.com/633377e113e587136ab4476b93d57f91
Here’s the code also:
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
if Humanoid then
Humanoid.BreakJointsOnDeath = false
Humanoid.Died:Connect(function()
Character.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(0.5),0,0)
local Dust = Lighting:WaitForChild("Assets"):WaitForChild("Death"):WaitForChild("Dust"):Clone()
Dust.Parent = Character
Dust.CFrame = Character.HumanoidRootPart.CFrame
local DustSFX = Lighting:WaitForChild("Assets"):WaitForChild("Death"):WaitForChild("DustSFX"):Clone()
DustSFX.Parent = Character
DustSFX:Play()
print("k")
for i, v in pairs(Character:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("UnionOperation") then
v.Anchored = true
game:GetService("TweenService"):Create(v, TweenInfo.new(DustSFX.TimeLength), {Transparency = 1}):Play()
elseif v:IsA("Decal") then
game:GetService("TweenService"):Create(v, TweenInfo.new(DustSFX.TimeLength), {Transparency = 1}):Play()
end
end
Dust.Floaters.Rate = 0
wait(1.5)
local Soul = Lighting:WaitForChild("Assets"):WaitForChild("Death"):WaitForChild("Soul"):Clone()
Soul.Parent = Character
Soul.CFrame = Character.HumanoidRootPart.CFrame
game:GetService("TweenService"):Create(Soul, TweenInfo.new(0.1), {Transparency = 0,CFrame = Soul.CFrame * CFrame.new(0.5,0,0)}):Play()
wait(0.1)
game:GetService("TweenService"):Create(Soul, TweenInfo.new(0.1), {CFrame = Soul.CFrame * CFrame.new(-1,0,0)}):Play()
wait(0.1)
game:GetService("TweenService"):Create(Soul, TweenInfo.new(0.1), {CFrame = Soul.CFrame * CFrame.new(1,0,0)}):Play()
wait(0.1)
game:GetService("TweenService"):Create(Soul, TweenInfo.new(0.1), {CFrame = Soul.CFrame * CFrame.new(-1,0,0)}):Play()
wait(0.1)
game:GetService("TweenService"):Create(Soul, TweenInfo.new(0.1), {CFrame = Soul.CFrame * CFrame.new(1,0,0)}):Play()
wait(0.1)
game:GetService("TweenService"):Create(Soul, TweenInfo.new(0.1), {CFrame = Soul.CFrame * CFrame.new(-1,0,0)}):Play()
wait(0.1)
game:GetService("TweenService"):Create(Soul, TweenInfo.new(0.1), {CFrame = Soul.CFrame * CFrame.new(0.5,0,0)}):Play()
wait(0.11)
local BrokenSoul = Lighting:WaitForChild("Assets"):WaitForChild("Death"):WaitForChild("BrokenSoul"):Clone()
BrokenSoul.Parent = Character
BrokenSoul.Main.Anchored = false
BrokenSoul.Main.CFrame = Soul.CFrame
BrokenSoul.Main.Anchored = true
Soul:Destroy()
local SoulBreakSFX = Lighting:WaitForChild("Assets"):WaitForChild("Death"):WaitForChild("SoulBreakSFX"):Clone()
SoulBreakSFX.Parent = Character
SoulBreakSFX:Play()
wait(1)
for i, v in pairs(BrokenSoul:GetDescendants()) do
if v:IsA("Motor6D") then
v:Destroy()
end
end
for i, v in pairs(BrokenSoul:GetChildren()) do
if v:IsA("Part") then
v.Anchored = false
v.CanCollide = false
v.Velocity = Vector3.new(math.random(-20,20),20,math.random(-20,20))
v.RotVelocity = Vector3.new(math.random(-20,20),20,math.random(-20,20))
end
end
end)
end
end)
(I know the code is inefficient right now, I just made it quickly to test if it works.)
Any help is appreciated!