It’s best to put it in ServerScriptService since this is a script that handles the PlayerAdded event.
This function fires when a new player joins, so each player will have a folder of BoolValues in them. You already have a player parameter, so the parameter defines the player who had joined.
Also, what do you mean by making it go into the player’s username in the Players default folder?
I think he means where the folder would go into the player. Yes, the script would go in ServerScript, but the folder would go into the players backpack when they join.
You know, you could just put the folder in the player by just doing folder.Parent = player so then it would just put the folder in the player, basically like the one in your picture.
It doesn’t go into starter pack. it goes under the default backpack roblox assigns when you join the game. Whatever is in the Starter Pack would replicate to this.
I’m making a checker to see if a player is in my group. Since yesterday from what I posted, this has been what it has been led up to. You can see the other post here.
I think leaderstats would be a great way to do that.
All unnecessary functions in this game (backpack,leaderboards, etc.) have been hidden
Hmmm, if it’s not working, this may be a solution but I’m not so sure.
script:
function playerAdded(player)
local folder = Instance.new("Folder")
folder.Name = "BoolValues"
folder.Parent = player
local value = Instance.new("BoolValue")
value.Name = "ChillBool"
value.Parent = folder
value.Value = false
end
game.Players.PlayerAdded:Connect(playerAdded)
for _,player in pairs(game.Players:GetPlayers()) do
spawn(function() playerAdded(player) end)
end
If you are trying to make a system to check to see if the player has a certain rank in your group or is in your group, you would make a folder parented to the players backpack.
Alright I think it’s a good idea to rewrite the beginning of the script bc it’s gotten pretty bad. I’ll start with your example, @Koriyoc
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local ChillBool = Instance.new("BoolValue")
ChillBool.Name = "ChillBool"
ChillBool.Parent = leaderstats
ChillBool.Value=false
end)
local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("ChillRemoteEvent")
local Chill = false
local inGroup = false
print("Starting first check")
print("Starting check to see if player is in group")
print ("Player is in Weird Games, Inc.!" )
inGroup = true
else
print("First check to see if player was in group failed. Trying 10 times, once every second, to see if they are really in the group")
for count = 1,10,1 do
wait(1)
if newPlayer:IsInGroup(6967967) then
print ("Player is in Weird Games, Inc.!" )
inGroup = true
end
end
end
You are running this inside of a local script, where is this local script located?
In order for the code to run it must be a desendent of PlayerGui, PlayerScripts or the player’s character.
Make sure it is under one of these locations and the event is being triggered:
Under PlayerAdded:Connect add a print statement so you can confirm the handler is running.
Secondly, because this is a local script you should only be doing this action for the current player.
This can be done through Players.LocalPlayer rather than the PlayerAdded event.
Avoid using PlayerAdded in local script as you only need to check the current player
Alternatively, you could move this into a server script and continue to use the PlayerAdded event.
This would be the best option since it gives the server control of the checks and any changes will be replicated to all clients.
Move the code into a script under ServerScriptServer, this must be a Script not a LocalScript