Script failing to find a boolvalue in the player

  1. What do you want to achieve? A fix to this.

  2. What is the issue? A script, located in ServerScriptService creates a boolvalue for each players in the game. However, another script that is also located in ServerScriptService can’t find boolvalue that is located in the player. But for some weird reason, it actually haven’t been printed into the player.

  3. What solutions have you tried so far? I’ve made print statement that prints it out when the boolvalue is created, and yes it printed but still getting the error.

Here is the code that creates the boolvalue…

local Players = game:GetService("Players")

wait(1)

for _, player in pairs(Players:GetPlayers()) do
	
	local boolValue = Instance.new("BoolValue")
	boolValue.Name = "hasDied"
	boolValue.Value = false
	boolValue.Parent = player
	print("create bool")	-- it printed
end  

Try this

local Players = game.Players or game:GetService("Players")
local ActivePlayers = Players:GetPlayers()

for i = 1, #ActivePlayers do
     if ActivePlayers[i]:IsA("Player") and not ActivePlayers[i]:FindFirstChild("hasDied") then
         local PlayersWithoutBoolValue = ActivePlayers[i]
         local HasDied = Instance.new("BoolValue")
         HasDied.Name = "hasDied"
         HasDied.Value = false
         HasDied.Parent = PlayersWithoutBoolValue
     end
end
1 Like

This works, thanks! Spent hours trying to fix this.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.