Basically, when I make this script it runs but it only works on one person. So the first person to join the game only gets a nametag. However, I don’t understand why the nametag doesn’t go on other peoples heads as the script clearly works but it only works for one person? Can somebody help me, I’m confused.
local groupid = 9668219
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local nclone = script.pname:Clone()
local rclone = script.rank:Clone()
nclone.Parent = Character.Head
rclone.Parent = Character.Head
rclone.RankText.Text = Player:GetRoleInGroup(groupid)
nclone.NameText.Text = Player.Name
end)
end)
You cloned all the elements of the Overhead UI. Instead you can just clone the main thing.
Let’s say OvrGui is the Overhead GUI. Just clone that and all the elements inside it will also be cloned. And I think it matters where you store the billboard gui.
Try putting it in Replicated Storage/ServerStorage.
local groupid = 9668219
local ReplicatedStorage = game:GetService:("ReplicatedStorage")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local OvrGui = ReplicatedStorage.OverheadGui -- Make sure it's a billboard GUI.
local OvrClone = OvrGui:Clone() -- Cloning the whole billboard GUI.
OvrClone.Parent = game.Workspace -- OvrClone Parent should be workspace I reckon.
OvrClone.Position = Character.Head.Position -- OvrClone position.
OvrClone.RankText.Text = Player:GetRoleInGroup(groupid)
OvrClone.NameText.Text = Player.Name
end)
end)
Try this script.
EDIT: Adding on, you did not position the Overhead GUI when you parented it.
Oh. Then, try just parenting it to the head instead of positioning it.
local groupid = 9668219
local ReplicatedStorage = game:GetService:("ReplicatedStorage")
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local OvrGui = ReplicatedStorage.OverheadGui -- Make sure it's a billboard GUI.
local OvrClone = OvrGui:Clone() -- Cloning the whole billboard GUI.
OverClone.Parent = game.Workspace:WaitForChild(parent.Name).Head
OvrClone.RankText.Text = Player:GetRoleInGroup(groupid)
OvrClone.NameText.Text = Player.Name
end)
end)
Put the script in ServerScriptService and make the pname and prank as one billboard GUI with different TextLabels called pname and prank. Put the whole billboard gui in ReplicatedStorage.
Like @0Enum said above, try placing the BillboardGuis in ReplicatedStorage.
And for your script, maybe get the character from Workspace instead of from the CharacterAdded event (I had a similar problem, but I fixed it by getting the character from Workspace)
See if this code works:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local nameGui = ReplicatedStorage:WaitForChild("pname")
local rankGui = ReplicatedStorage:WaitForChild("rank")
local groupid = 9668219
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
wait()
local nClone = nameGui:Clone()
local rClone = rankGui:Clone()
nClone.NameText.Text = plr.Name
rClone.RankText.Text = plr:GetRoleInGroup(groupid)
nClone.Parent = game.Workspace:WaitForChild(plr.Name).Head
rClone.Parent = game.Workspace:WaitForChild(plr.Name).Head
end)
end)