Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I tried to get the Boolvalues in a player, but I can't get them?

In the player, there are Intvalues as well as Boolvalues. I tried getting all Boolvalues (All Roles that were purchased by the player), but the output is just blank. There is no error and the printmessage doesn't appear.

RolesTable = {}


game.Players.PlayerAdded:Connect(function(plr)
plr:WaitForChild("Stats")	
	local Roles = plr.Stats:GetChildren()
	for i,v in pairs(Roles)
	do
		if v == true 
		then
			table.insert(RolesTable,1,v)
		end
	end
	print(table.concat(RolesTable))
end)

Thanks in advance.

1 answer

✓ Accepted answer
local Players = game:GetService("Players")

local function GetActiveRoles(Player)
    local ActiveRoles = {}
    local Stats = Player:WaitForChild("Stats")
    for _,Role in pairs(Stats:GetChildren()) do
        if (Role.Value ~= false) then
            table.insert(ActiveRoles, Role.Name)
        end
    end
    print(unpack(ActiveRoles))
end

Players.PlayerAdded:Connect(GetActiveRoles)

This discussion is preserved as it was. New answers, comments, and votes are closed.