Hello. I am making this tagging game where there are safe areas. I am making a variable for each player called invincibility. Please do not tell me to do this with a different method because I just wanna use this method and this method is very important. Why does my code not work?
local Players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(player)
local invincibility = Instance.new("BoolValue")
invincibility.Name="invincibility"
invincibility.Value=false
invincibility.Parent=player
local PlayerCount = #Players:GetPlayers()
local it
if PlayerCount==1 then
it=player
print(player.Name .. " is it!")
player.invincibility=true
end
end)
Output:
betweenplacements is it!
10:35:04.122 - invincibility is not a valid member of Player
10:35:04.124 - Stack Begin
10:35:04.124 - Script 'Workspace.Script', Line 12
10:35:04.124 - Stack End

1 comment
In that script, you could just use the already provided invincibility.Value, but otherwise you need to specify that you want to change the value.