local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
while wait() do
if Character:WaitForChild("HumanoidRootPart"):FindFirstChild("Running").Playing == true then
if LocalPlayer.InGame.Game.Value == true and LocalPlayer.InGame.CanWalk.Value == false then
Character:WaitForChild("Humanoid").Health = 0
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Died:Connect(function()
--Do any script here that will run after a player dies
end)
end)
end)
any errors in output? it should work, also try to write game with lovercase g, i’m not sure if it works with “Game”. Try to print something instead of your script after Died event
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local Humanoid = character:waitForChild('Humanoid')
Humanoid.Died:Connect(function()
--Do any script here that will run after a player dies
end)
end)
end)
Because you put the character outside of the loop it wont re-check the character. Try putting it inside the loop like this:
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
while wait() do
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
if Character:WaitForChild("HumanoidRootPart"):FindFirstChild("Running").Playing == true then
if LocalPlayer.InGame.Game.Value == true and LocalPlayer.InGame.CanWalk.Value == false then
Character:WaitForChild("Humanoid").Health = 0
end
end
end