So I made this script you can ignore the part in the middle, but at the end where the players health is set to 0 nothing happends and the printing around it does print. I’ve tried mulitple ways to kill the player already.
game.Players.PlayerAdded:Connect(function(player)
local values = Instance.new("Folder")
values.Name = "Values"
values.Parent = player
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
local newStage = player.leaderstats.Stage.Value + 1
player.leaderstats.Stage.Value = newStage
player.CharacterAdded:Wait()
local text = "Stage "..newStage..": "..stageNames[newStage]
wait(2)
textRemote:FireClient(player, text)
if newStage == 7 then
playSoundRemote:FireClient(player, voiceStage7)
for i,v in pairs(replicatedStorage.Rooms.Room7:GetChildren()) do
local newZombie = v:Clone()
newZombie.Parent = workspace.Rooms.Room7.ZombieFolder
end
local newAgeValue = Instance.new("IntValue")
newAgeValue.Name = "Age"
newAgeValue.Parent = player.Values
for i = 1,76,1 do
wait(0.1) -- change back to 1.2, 1.3, 1.4 or 1.5
newAgeValue.Value += 1
if player.leaderstats.Stage.Value == 8 and i < 75 then
player.CharacterAdded:Wait()
wait(2)
deathScreenRemote:FireClient(player)
end
end
print("Done") -- prints
wait(10)
print("Done2") -- prints
character:FindFirstChild("Humanoid").Health = 0 -- here it does nothing
end
end)
end)
end)
Make a BindableEvent in ServerStorage and name it SetPlayerHealth.
-- Script 1
local bindableEvent = game:GetService("ServerStorage"):WaitForChild("SetPlayerHealth")
game.Players.PlayerAdded:Connect(function(player)
local values = Instance.new("Folder")
values.Name = "Values"
values.Parent = player
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
local newStage = player.leaderstats.Stage.Value + 1
player.leaderstats.Stage.Value = newStage
player.CharacterAdded:Wait()
local text = "Stage "..newStage..": "..stageNames[newStage]
wait(2)
textRemote:FireClient(player, text)
if newStage == 7 then
playSoundRemote:FireClient(player, voiceStage7)
for i,v in pairs(replicatedStorage.Rooms.Room7:GetChildren()) do
local newZombie = v:Clone()
newZombie.Parent = workspace.Rooms.Room7.ZombieFolder
end
local newAgeValue = Instance.new("IntValue")
newAgeValue.Name = "Age"
newAgeValue.Parent = player.Values
for i = 1,76,1 do
wait(0.1) -- change back to 1.2, 1.3, 1.4 or 1.5
newAgeValue.Value += 1
if player.leaderstats.Stage.Value == 8 and i < 75 then
player.CharacterAdded:Wait()
wait(2)
deathScreenRemote:FireClient(player)
end
end
print("Done") -- prints
wait(10)
print("Done2") -- prints
bindableEvent:Fire(0)
end
end)
end)
end)
-- Script 2 (Server Script)
local bindableEvent = game:GetService("ServerStorage"):WaitForChild("SetPlayerHealth")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
bindableEvent.Event:Connect(function(health)
character:FindFirstChildOfClass("Humanoid").Health = health
end)
end)
end)