Script isnt working with R15

I have a script that displays an overhead gui that shows display name, username and level. It seems to be perfectly working with R6 characters but when I switch over to R15 characters which is what my game will be the script no longer works at all.

The script:

local OverheadGui = script.OverheadGui:Clone()

local function updateOverheadGui(player)
	local character = player.Character
	if character then
		local leaderstats = player:WaitForChild("leaderstats")
		local level = leaderstats:WaitForChild("Level")

		OverheadGui.Username.Text = player.DisplayName .. " (@" .. player.Name .. ")"
		OverheadGui.Level.Text = "Level: " .. level.Value
		OverheadGui.Parent = character:WaitForChild("Head")

		level.Changed:Connect(function(newValue)
			OverheadGui.Level.Text = "Level: " .. newValue
		end)
	end
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		updateOverheadGui(player)
	end)
	updateOverheadGui(player)
end)

image

Maybe try this? :

local function updateOverheadGui(player, character)
	local leaderstats = player:WaitForChild("leaderstats")
	local level = leaderstats:WaitForChild("Level")

	local OverheadGui = script:WaitForChild("OverheadGui"):Clone()
	OverheadGui.Username.Text = player.DisplayName .. " (@" .. player.Name .. ")"
	OverheadGui.Level.Text = "Level: " .. level.Value
	OverheadGui.Parent = character:WaitForChild("Head")

	level.Changed:Connect(function(newValue)
		OverheadGui.Level.Text = "Level: " .. newValue
	end)
end

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		updateOverheadGui(player, character)
	end)
end)

Does not seem to change anything. I am getting the error “Level is not a valid member of BillboardGui “OverheadGui”” in the console though.

Maybe it hasn’t loaded in yet? Try this for the overhead ui part:

local OverheadGui = script:WaitForChild("OverheadGui"):Clone()
OverheadGui:WaitForChild("Username").Text = player.DisplayName .. " (@" .. player.Name .. ")"
OverheadGui:WaitForChild("Level").Text = "Level: " .. level.Value
OverheadGui.Parent = caracter:WaitForChild("Head")

Same issue, same error… Before I made the DevForum post I tried everything I could to fix it and still couldn’t fix the issue.

Maybe the issue is on a different part of the code then, because the code you wrote is correct

It works on R6 but when I switch to R15 that’s when it no longer works.

If that’s the only code you have in the game it’s very weird, I tried it in my open studio just now and it works fine.

Thats weird then since I don’t have many other scripts in my game other than a music system and leaderstats.

Is Level spelt correctly on the TextLabel? Sometimes there might be a trailing space at the end or at the beginning that could cause an error. These are different things Level and Level

Just checked to make sure and nope there aren’t any spaces… Which is expected since it works on R6 just not R15

Just figured out the issue… So I took off my headless head and then it works. I never thought of this as when I joined the studio it still said I had a head (which is in the image). Why does it not work with the headless head since it’s still a head just transparent.
image

1 Like

bruh

Maybe try putting it on the HRP instead of the head?

2 Likes

Works now. Thank you for your help.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.