How would I change boolvalue on playerdeath?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Change BoolValue that is within a local player on death

  2. What is the issue? Include screenshots / videos if possible!
    I can’t find the value within the player

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I have tried using .localplayer:FindFirstChild but it never works
    After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

-- Creating the value
game.Players.PlayerAdded:Connect(function(player)
	local InLobby = Instance.new("BoolValue")
	InLobby.Parent = player
	InLobby.Name = "InLobby"
	InLobby.Value = true
end)

Local Script
local InLobby = game.Players.LocalPlayer:WaitForChild("InLobby")
game.Players.LocalPlayer:FindFirstChild("InLobby")

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

3 Likes

is that a local script? if so
you don’t need PlayerAdded Event
you can do

local player = game.Players.LocalPlayer
local InLobby = Instance.new("BoolValue")
	InLobby.Parent = player
	InLobby.Name = "InLobby"
	InLobby.Value = true

also remove “Local Script”

The first script is a server script creating the value and the second one is a local script that im using to try to change the value to true on a players death. How would i do that?

can I just ask why you are changing the value with the local script, just a simple question. I don’t see the point of creating a value on the server just to change it on the client.

game.Players.PlayerAdded:Connect(function(player)
	local InLobby = Instance.new("BoolValue")
	InLobby.Parent, InLobby.Name, InLobby.Value = player, "InLobby", true
	
	player.CharacterAdded:Connect(function(char)
		if InLobby.Value ~= true then
			local hum = char:FindFirstChild('Humanoid', true)
			if (hum) then
				hum.Died:Connect(function()
					InLobby.Value = true
				end);
			end;
		end;
	end);
end);

Inside of a server script, this should do what you want.

1 Like