function onPlayerAdded(plr)
--your player added code here
end
for _, player in players:GetPlayers() do
onPlayerAdded(player)
end
players.PlayerAdded:Connect(onPlayerAdded)
its working, the problem is probably at the char
script:
But does the other player added work?
Just move the character added into this one, itâs a good practice if the server lags.
Also, what are the settings for your name tag BillboardGui?
sorry im a little confused, also is the settings the properties? sorry I havent scripted for a while now and forgot some things
Just simply a properties window screenshot of the BillboardGui
.
Okay, they look fine. Does it work when you set the Adornee
of it in studio and parent it to Workspace
?
also, the first player added is working, idk if what I did is right because I just added print between the player added and character added
Yes, itâs right, but since both methods work, no change is necessary.
The BillboardGui is likely the problem.
I tried renaming it and it still doesnt work, I also added it to a brick and it work just fine
``Try disabling ClipsDescendants
, that might be the problem?
Try disabling ResetOnSpawn
. That might be an issue.
Also, be sure to check for errors in the output view. There might be something you missed.
still no, also I made it go into the baseplate instead of the head and it works in there
This has happened to me before, it worked fine w/ r6, but did not do anything w/ r15.
I just gave up and ended up parenting any billboard ui to the head or HumanoidRootPart and setting an offset or using an attachment
Maybe try doing it with an r6 avatar and see if it changes anything
Try putting a task.wait(2)
before you set the Parent
property of the BillboardGui
.
oh yeah it worked on r6, idk whats up with that but thanks
np, the head on r15 must be weird, as it just does not work. If you want to get around it use an attachment on the characterâs humanoid root part.
The script would make a new attachment and set the Position to 0,5,0 or something, and then would put the gui in the attachment. You could prob do some math based off of the characterâs scale to get the correct height
All body types (r6, r15, rthro) should have a Humanoid Root Part
Your Code should be working, if your PlayerAdded
Event is running, its likely that CharacterAdded
never ran, which can happen from time to time, but if its constantly happening, there is likely something wrong with your NameTag, or a piece of code that you arenât showing that is likely causing your code to yield.
Although this isnt what you are asking, nor what you are concerned about concerned about, you can do this with your code:
If you wanted to, you can have a function for getting the Color of the Tag, thats needed if the Player is the Owner or not, like so:
local function ApplyC3(t, userId)
for i,v in t do
local boolean = (v == userId) -- returns a boolean
if not boolean then continue end -- skips iteration if boolean is false
return userResult[boolean] -- returns Color Code from boolean
end
end
Which you might be why to get a Color based off a Boolean, this code here would basically show why, or how you cna do this:
local Rep = game:GetService("ReplicatedStorage") -- ReplicatedStorage
local Players = game:GetService("Players") -- game.Players
local owners = {game.CreatorId} -- owner list
local userResult = { -- just to store if a value is true or not, usage is for when if you are the owner or not
[true] = Color3.fromHex(486949); -- can be access if you index 'true' of if a condition is true
[false] = Color3.fromHex("ffffff"); -- default value if the condition is false
}
-- The Color's are just HexCode, Sorry about that.
local function ApplyC3(t, userId)
for i,v in t do
local boolean = (v == userId) -- returns a boolean
if not boolean then continue end -- skips iteration if boolean is false
return userResult[boolean] -- returns Color Code from boolean
end
end
Players.PlayerAdded:Connect(function(p) -- PlayerAdded
p.CharacterAdded:Connect(function(c) -- CharacterAdded
local ui = OverheadGui:Clone() -- UI Clone
ui.Display.Text = p.DisplayName -- DisplayName
ui.Username.Text = `@{p.Name}` -- Another way of concatenating
ui.Rank.TextColor3 = ApplyC3(owners, p.UserId) -- should Apply a Color based of the arguments given, since we have a key named 'true' and 'false' insise 'userResult'
ui.Parent = c.Head -- Apply Parent after you Apply the Properties to your
end)
end)
Eh, thats not exactly true, however Its Recommended that you place the NameTag inside the HumanoidRootPart
rather than the Head
.
All Body Types also have a head
it works on the root part, but will the height of the player and the head size affect the position of the ui?