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

Why does my group only gear script not even work?

My group only tools don't work, some reason when a tool has a number in it.

Why does this even happen?

group = (4309200)
game.Players.PlayerAdded:Connect(function(player)
	 local Level_0 = player:GetRankInGroup(group)
	if Level_0.player:GetRankInGroup(group) == 255 then
		local level_0 = game:GetService("ReplicatedStorage").Level0
		level_0.L_X:Clone()
		level_0.L_X.Parent = game.Players.LocalPlayer.Backpack
	end
end)

Error1: "20:04:24.966 - Workspace.Script:4: attempt to index local 'Level_0' (a number value)"

1 answer

✓ Accepted answer

It's because GetRankInGroup returns the rank of the group they are in and you're trying to index a number. It also didn't work because LocalPlayer is nil on server scripts. It works in LocalScript only. And because PlayerAdded has a player parameter you can use that instead. LocalPlayer only works on LocalScript because it is a descendant of the player, like the PlayerGui, maybe GUIS inside there, the backpack, the character which belongs to the player but it's not a child of the player.

local group = 4309200 --//local variables are faster

game.Players.PlayerAdded:Connect(function(player)
     local Level_0 = player:GetRankInGroup(group)
     if Level_0 == 255 then
        local level_0 = game:GetService("ReplicatedStorage").Level0
        local clone = level_0.L_X:Clone()
        clone.Parent = player:WaitForChild"Backpack"
    end
end)

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