Greetings, Developers! I need to change the bool value within the player script when the player dies. I have a script that creates a new bool value when the player enters the game, and I need another script to change the value to false when the player dies. Hope I explained it more clearly this time.
This script creates new value
local PM = game.Workspace.Arena.Give
local SZ = game.Workspace.Arena.remover.Remover
local UN = game.Workspace.Arena.Untouch
game.Players.PlayerAdded:Connect(function(plr)
local PVP = Instance.new("BoolValue")
PVP.Name = "Isworking"
PVP.Value = false
PVP.Parent = plr
end)
PM.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.Isworking.Value = true
end
end)
PM.TouchEnded:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.Isworking.Value = false
end
end)
The script which should check It
game.Players.PlayerAdded:Connect(function(plr)
task.spawn(function()
local player = plr
repeat task.wait() until player.Character
local humanoid = player.Character:FindFirstChild("Humanoid")
humanoid.Died:Connect(function()
plr:WaitForChild("Isworking").Value = false
end)
end)
end)
game.Players.PlayerAdded:Connect(function(plr)
local player = plr
local humanoid = player.Character:FindFirstChild("Humanoid")
humanoid.Died:Connect(function()
plr:WaitForChild("Isworking").Value = false
end)
end)
1 - Check If you using client for died function, if so make it server or use remote event
2 - After player dies, system still checks if player touching the area and changes the “Isworking” value to true, do something like this; “if Humanoid.Health > 0 then” so it will only change the value if player is alive. Hope it’s works for you.