Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
0
Answered by 10 years ago
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

0
It's a BoolValue. I have other BoolValues that I have changed to true or false. systematicaddict 295 — 10y
0
Oh I thought a regular value.... Well can you give me the layout then i'll try to figure it out RolandStudio 115 — 10y
0
I edited the question. systematicaddict 295 — 10y
0
thx RolandStudio 115 — 10y
Ad
Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

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)

Answer this question