I am making a game in which players must escape from a monster, and I thought adding a boolvalue for each player to tell whether they have escaped or not would be a good idea.
However, I cannot figure out how to add the value to the folder when they join.
This is the code I have:
local player = game.Players:GetPlayers() local EscapeValue = Instance.new("BoolValue") EscapeValue.Name = player.Name EscapeValue.Parent = game.ServerStorage.PlayerEscaped EscapeValue.Value = false
Any help is appreciated.
Just store the names of the players in a table
local whoEscaped = {} --when someone escapes: whoEscaped[plr.Name] = true --when someone unescapes or something: whoEscaped[plr.Name] = nil --when you need to check if they escaped: if whoEscaped[plr.Name] then print("escaped") else print("didn't escape") end --also make sure to remove them from the table when they leave the game: game:GetService("Players").PlayerRemoving:Connect(function(plr) whoEscaped[plr.Name] = nil end)