I’m trying to make an overheadgui but I’ve run into an error, I don’t know how to fix it.
Script:
--- // VARIABLES // ---
local ServerStorageService = game:GetService('ServerStorage')
local RankUi = ServerStorageService:WaitForChild('RankGui')
local UsernameUi = ServerStorageService:WaitForChild('UsernameGui')
--- // MAIN CODE // ---
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local RankUiClone = RankUi:Clone()
local UsernameUiClone = UsernameUi:Clone()
RankUiClone.Parent = char.Head
UsernameUiClone.Parent = char.Head
RankUiClone.Frame:FindFirstChild('TextLabel').Text = plr:GetRoleInGroup(959294)
UsernameUiClone.Frame:FindFirstChild('TextLabel').Text = plr.Name
end)
end)
Dev Console Server Output:
3 Likes
kitywoIf
(kitywolf)
July 20, 2020, 10:08am
#2
There seems to be nothing wrong with the code, does RankUiClone
contain a Frame
and a TextLabel
in the frame respectively?
BanTech
(BanTech)
July 20, 2020, 10:14am
#3
Why are you using FindFirstChild as opposed to just directly referencing the TextLabel, when you’ve directly referenced absolutely everything else.
If you know there’s a chance that TextLabel doesn’t exist, then that immediately points towards the problem.
It’s very strange to use FindFirstChild unless the name is in a variable, contains characters such as a space, or it is not known whether it exists or not and therefore you can use the result in a conditional check.
Try using WaitForChild instead of FindFirstChild to find “TextLabel”
It couldn’t find the TextLabel
before, so I decided to try and use :FindFirstChild()
.
kitywoIf
(kitywolf)
July 20, 2020, 10:21am
#7
That should not make a difference though. If the TextLabel
does not exist, then FindFirstChild()
would return false. But it will not increase the chances of it being found.
The result in Developer Console Server output:
Also, it didn’t even put the GUI above my head.
kitywoIf
(kitywolf)
July 20, 2020, 10:22am
#9
Oh if it is an Infinite Yield, it means that the TextLabel
does not exist. Most likely.
kitywoIf
(kitywolf)
July 20, 2020, 10:23am
#11
In the output panel it says airsoft561.Head.RankGui.Frame:WaitForChild()
and not the code you mentioned above, is that a different script?
Edit: My bad.
Is it a local script or server script?
Check both client and server in studio in play mode.
airsoft561
(airsoft561)
July 20, 2020, 10:24am
#13
I forgot to say, I changed it on @TheMirrorGameCreator ’s reply.
Also, I checked the explorer on studio, and somehow the text label DOES NOT exist for some reason.
kitywoIf
(kitywolf)
July 20, 2020, 10:25am
#14
Perhaps the head has not loaded in yet. Try this:
--- // VARIABLES // ---
local ServerStorageService = game:GetService('ServerStorage')
local RankUi = ServerStorageService:WaitForChild('RankGui')
local UsernameUi = ServerStorageService:WaitForChild('UsernameGui')
--- // MAIN CODE // ---
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local RankUiClone = RankUi:Clone()
local UsernameUiClone = UsernameUi:Clone()
local Head = char:WaitForChild("Head")
RankUiClone.Parent = Head
UsernameUiClone.Parent = Head
RankUiClone.Frame:FindFirstChild('TextLabel').Text = plr:GetRoleInGroup(959294)
UsernameUiClone.Frame:FindFirstChild('TextLabel').Text = plr.Name
end)
end)
airsoft561
(airsoft561)
July 20, 2020, 10:25am
#15
Server Script, also, client had nothing in it other then this which is not related to the script:
[No, it’s not a virus]
kitywoIf
(kitywolf)
July 20, 2020, 10:27am
#16
Then in that case, is there a possibility it is being deleted by another script? You could try using Alt+F
(or shift+F I can’t remember) to search all scripts.
airsoft561
(airsoft561)
July 20, 2020, 10:28am
#17
Back to square 1, same error.
Also, the textlabel is STILL not in the gui.
kitywoIf
(kitywolf)
July 20, 2020, 10:29am
#18
What about this? That is the only thing I can think of. Perhaps something like:
for i,v in pairs(character.Head:GetDescendants()) do
if v:IsA("TextLabel") then
v:Destroy()
end
end
Only thing I can think of, though it would be a weird script though…
airsoft561
(airsoft561)
July 20, 2020, 10:30am
#19
Checked, I searched up Destroy
Delete
and Remove
in the advanced search tab, no scripts had it.
FerbZides
(FerbZides)
July 20, 2020, 10:30am
#20
uhh maybe put those gui in replicated storage and change some of the scripts??!?!?