So i’m trying to code this so that it’ll kill all players and play an animation before it kills them but they die before the animation plays
local Snap = script.Animation
local Workspace = game.Workspace
local descendant = game.Workspace:GetDescendants()
local function Plague()
if descendant:IsA("Humanoid") then
local humanoid = descendant
Snap:Play()
wait(4)
humanoid.Character.Humanoid:TakeDamage(100)
end
end
local function Plague()
if descendant:IsA("Humanoid") then
local humanoid = descendant
Snap:Play()
end
Snap.Completed:Connect(function()
descendant.Character.Humanoid:TakeDamage(100)
end
)
As ript said, you should use Animation.Completed but I don’t know here it is your script but you should put it in the server script service and there you go the code:
game.Players.PlayerAdded:Connect(function(player)
local Snap = script.Animation
local Workspace = game.Workspace
local descendant = game.Workspace:GetDescendants()
for i,v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
local hum = v:FindFirstChild("Humanoid")
local anim = hum:LoadAnimation(Snap)
anim:Play()
anim.Completed:Connect(function()
hum:TakeDamage(100)
print(hum.Parent.Name.. " died.")
end)
end
end
end)
local function plage()
local Snap = script.Animation
for i,v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
local hum = v:FindFirstChild("Humanoid")
local anim = hum:LoadAnimation(Snap)
anim:Play()
anim.Completed:Connect(function()
hum:TakeDamage(100)
print(hum.Parent.Name.. " died.")
end)
end
end
end
--SCRIPT WRITTEN BY CLEETUSCHAN--
local Players = game.Players:GetChildren()
local Workspace = game.Workspace
local descendant = game.Workspace:GetDescendants()
local function Neck()
local Snap = script.Animation
for i,v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
local hum = v:FindFirstChild("Humanoid")
local anim = hum:LoadAnimation(Snap)
anim:Play()
anim.Completed:Connect(function()
hum:TakeDamage(100)
print(hum.Parent.Name.. " died.")
end)
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if (msg == "May you rest in peace.") then
Neck()
end
end)
end)
local function neck()
local Snap = script.Animation
for i,v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
local hum = v:FindFirstChild("Humanoid")
local anim = hum:LoadAnimation(Snap)
anim:Play()
anim.Stopped:Connect(function()
hum:TakeDamage(100)
print(hum.Parent.Name.. " died.")
end)
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if (msg == "May you rest in peace.") then
neck()
end
end)
end)
It’s still not working right. I just die and it doesn’t play the animation. No errors either
--SCRIPT WRITTEN BY CLEETUSCHAN--
local Players = game.Players:GetChildren()
local Workspace = game.Workspace
local descendant = game.Workspace:GetDescendants()
local function Neck()
local Snap = script.Animation
for i,v in pairs(game.Workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") then
local hum = v:FindFirstChild("Humanoid")
local anim = hum:LoadAnimation(Snap)
anim:Play()
anim.Stopped:Connect(function()
hum:TakeDamage(100)
print(hum.Parent.Name.. " died.")
end)
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if (msg == "May you rest in peace.") then
Neck()
end
end)
end)
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if (msg == "May you rest in peace.") then
Neck()
end
end)
end)