I am currently working on an arcade game where players have access to play several different games.
I’d like to implement a system that checks if a player is already playing a game. For example, a player clicks a Gui, granting them access to a game. A variable is set to true, preventing them from trying to play multiple games. The variable is set to false upon finishing playing the game.
What would be the best approach to this? What type of variable would I use?
To find an attribute you need to go to the propertys tap and scroll all the way down to where it says “attributes” and then add one. but in your case you would need to create an atributte for every player that joins. try a script like this.
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
-- Check if the attribute already exists just in case
if humanoid:GetAttribute("MyBool") == nil then
humanoid:SetAttribute("MyBool", false)
end
end)
end)
^^^^^^^^^^
this script goes in server script service and creates an attribute for every player that joins