Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How would I make an in-game BoolValue change to false when a person dies?

So I have a global script inside the Workspace, here's what's in it.

for i,v in pairs(game.Players:GetPlayers()) do
	if v.Character:FindFirstChild("Humanoid") then
		v.Character.Humanoid.Died:connect(function()
			v.InGame.Value = false
		end)
	end
end

I also have a rounds script, that changes that value to true when the round starts, that script also kills the player. It changes the value true, and works 100%.

And I have a script that inserts this value into the player when the start:

game.Players.PlayerAdded:connect(function(p)
	ing = Instance.new("BoolValue")
	ing.Name = "InGame"
	ing.Value = false
	ing.Parent = p
end)

The script that doesn't work, is the first one.

--Edit for ToTo--

2 answers

for i,v in pairs(game.Players:GetPlayers()) do
    if v.Character:FindFirstChild("Humanoid") then
        v.Character.Humanoid.Died:connect(function()
            v.InGame.Value = 1
        end)
    end
end

Values can't be turned into True nor false. Try making the value into numbers. Make it so 1 = false and 0 = true

4 comments

0

It's a BoolValue. I have other BoolValues that I have changed to true or false.

0

Oh I thought a regular value.... Well can you give me the layout then i'll try to figure it out

0

I edited the question.

0

thx

You have to also use the PlayerAdded event in the first script because as it is now, it only will look through each player once and connect their Humanoid.Died event once. You have to connect Died every time the character respawns.

Game:GetService("Players").PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		char:WaitForChild("Humanoid").Died:connect(function()
			plr:FindFirstChild("InGame").Value = false
		end)
	end)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.