local groupid = 6693950 local text1 = script.Parent game.Players.PlayerAdded:Connect(function(plr) text1.Text = (plr:GetRoleInGroup(groupid)) end)
Script is a LocalScript
You can't do game.Players.PlayerAdded in localscripts. I suggest you making a RemoteEvent and call it "PlayerGroup" and put it in ReplicatedStorage.
Here is the the script you need to make in ServerScriptService:
rp = game:GetService("ReplicatedStorage") playergroup = rp:WaitForChild("PlayerGroup") game.Players.PlayerAdded:Connect(function(plr) local roleplr = plr:GetRoleInGroup(3336691) print(plr, "is", roleplr) -- This is useful for testing playergroup:FireAllClients(plr, roleplr) end)
And this your localscript:
local text1 = script.Parent local rp = game:GetService("ReplicatedStorage") local playergroup = rp:WaitForChild("PlayerGroup") player = game.Players.LocalPlayer playergroup.OnClientEvent:connect(function(plr, rank) if plr ~= nil and plr.Name == player.Name then text1.Text = rank end end)