Why is there an error here?

I’m getting the error: HealthDisplay is not a valid member of Folder “Players.MrMatthewGamingX.PlayerGui.ScreenGui.UpperBars”

The line it directs me to is this line: game.Players.LocalPlayer.PlayerGui.ScreenGui.UpperBars.HealthDisplay = i.."/100"

I don’t know why it’s telling me it does not exist, here’s a screenshot of the explorer:
Screenshot 2023-03-03 220117

1 Like

It’s the child of Health, that’s why it’s erroring

I can’t exactly explain why it errors but I know that you can fix this by doing this

game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui"):WaitForChild("UpperBars"):WaitForChild("HealthDisplay")= i.."/100"

Or more effectively:

local Players = game:GetService("Players") -- Put at the top of the script
local Player = Players.LocalPlayer -- Put at the top of the script
local PlayerGui = Player.PlayerGui -- Put at the top of the script
local ScreenGui = PlayerGui:WaitForChild("ScreenGui") -- Put at the top of the script

local HealthDisplay = ScreenGui:FindFirstChild("HealthDisplay", true) -- Searches through the entire ScreenGui for the health display and returns it if found
-- HealthDisplay = i.."/100" and the rest goes here

Try game.Players.LocalPlayer.PlayerGui.ScreenGui.UpperBars.Health.HealthDisplay = i.."/100"

1 Like

sorry my picture was misleading. Here’s what it looks like when everything is collapsed:
Screenshot 2023-03-03 221524

when you’re referencing the health display, do you check for it in playergui or startergui?

I tried both referencing. Neither worked.

Oh sorry, my fault

PlayerGUI, it’s said in the error

would you be willing to show the script so i can take a look at the error?

Here’s the entire script. Sorry if this hurts to look at. It’s a health system and I’m not very good with them.

local HeathNums = {
	["100"] = UDim2.new(0.135, 0,1),
	["99"] = UDim2.new(0.13365, 0,1),
	["98"] = UDim2.new(0.1323, 0,1),
	["97"] = UDim2.new(0.13095, 0,1),
	["96"] = UDim2.new(0.1296, 0,1),
	["95"] = UDim2.new(0.12825, 0,1),
	 ["94"] = UDim2.new(0.1269, 0,1),
	 ["93"] = UDim2.new(0.12555, 0,1),
	 ["92"] = UDim2.new(0.1242, 0,1),
	 ["91"] = UDim2.new(0.12285, 0,1),
	 ["90"] = UDim2.new(0.1215, 0,1),
	 ["89"] = UDim2.new(0.12015, 0,1),
	 ["88"] = UDim2.new(0.1188, 0,1),
	 ["87"] = UDim2.new(0.11745, 0,1),
	 ["86"] = UDim2.new(0.1161, 0,1),
	 ["85"] = UDim2.new(0.11475, 0,1),
	 ["84"] = UDim2.new(0.1134, 0,1),
	 ["83"] = UDim2.new(0.11205, 0,1),
	 ["82"] = UDim2.new(0.1107, 0,1),
	 ["81"] = UDim2.new(0.10935, 0,1),
	 ["80"] = UDim2.new(0.108, 0,1),
	 ["79"] = UDim2.new(0.10665, 0,1),
	 ["78"] = UDim2.new(0.1053, 0,1),
	 ["77"] = UDim2.new(0.10395, 0,1),
	 ["76"] = UDim2.new(0.1026, 0,1),
	 ["75"] = UDim2.new(0.10125, 0,1),
	 ["74"] = UDim2.new(0.0999, 0,1),
	 ["73"] = UDim2.new(0.09855, 0,1),
	 ["72"] = UDim2.new(0.0972, 0,1),
	 ["71"] = UDim2.new(0.09585, 0,1),
	 ["70"] = UDim2.new(0.0945, 0,1),
	 ["69"] = UDim2.new(0.09315, 0,1),
	 ["68"] = UDim2.new(0.0918, 0,1),
	 ["67"] = UDim2.new(0.09045, 0,1),
	 ["66"] = UDim2.new(0.0891, 0,1),
	 ["65"] = UDim2.new(0.08775, 0,1),
	 ["64"] = UDim2.new(0.0864, 0,1),
	 ["63"] = UDim2.new(0.08505, 0,1),
	 ["62"] = UDim2.new(0.0837, 0,1),
	 ["61"] = UDim2.new(0.08235, 0,1),
	 ["60"] = UDim2.new(0.081, 0,1),
	 ["59"] = UDim2.new(0.07965, 0,1),
	 ["58"] = UDim2.new(0.0783, 0,1),
	 ["57"] = UDim2.new(0.07695, 0,1),
	 ["56"] = UDim2.new(0.0756, 0,1),
	 ["55"] = UDim2.new(0.07425, 0,1),
	 ["54"] = UDim2.new(0.0729, 0,1),
	 ["53"] = UDim2.new(0.07155, 0,1),
	 ["52"] = UDim2.new(0.0702, 0,1),
	 ["51"] = UDim2.new(0.06885, 0,1),
	 ["50"] = UDim2.new(0.0675, 0,1),
	 ["49"] = UDim2.new(0.06615, 0,1),
	 ["48"] = UDim2.new(0.0648, 0,1),
	 ["47"] = UDim2.new(0.06345, 0,1),
	 ["46"] = UDim2.new(0.0621, 0,1),
	 ["45"] = UDim2.new(0.06075, 0,1),
	 ["44"] = UDim2.new(0.0594, 0,1),
	 ["43"] = UDim2.new(0.05805, 0,1),
	 ["42"] = UDim2.new(0.0567, 0,1),
	 ["41"] = UDim2.new(0.05535, 0,1),
	 ["40"] = UDim2.new(0.054, 0,1),
	 ["39"] = UDim2.new(0.05265, 0,1),
	 ["38"] = UDim2.new(0.0513, 0,1),
	 ["37"] = UDim2.new(0.04995, 0,1),
	 ["36"] = UDim2.new(0.0486, 0,1),
	 ["35"] = UDim2.new(0.04725, 0,1),
	 ["34"] = UDim2.new(0.0459, 0,1),
	 ["33"] = UDim2.new(0.04455, 0,1),
	 ["32"] = UDim2.new(0.0432, 0,1),
	 ["31"] = UDim2.new(0.04185, 0,1),
	 ["30"] = UDim2.new(0.0405, 0,1),
	 ["29"] = UDim2.new(0.03915, 0,1),
	 ["28"] = UDim2.new(0.0378, 0,1),
	 ["27"] = UDim2.new(0.03645, 0,1),
	 ["26"] = UDim2.new(0.0351, 0,1),
	 ["25"] = UDim2.new(0.03375, 0,1),
	 ["24"] = UDim2.new(0.0324, 0,1),
	 ["23"] = UDim2.new(0.03105, 0,1),
	 ["22"] = UDim2.new(0.0297, 0,1),
	 ["21"] = UDim2.new(0.02835, 0,1),
	 ["20"] = UDim2.new(0.027, 0,1),
	 ["19"] = UDim2.new(0.02565, 0,1),
	 ["18"] = UDim2.new(0.0243, 0,1),
	 ["17"] = UDim2.new(0.02295, 0,1),
	 ["16"] = UDim2.new(0.0216, 0,1),
	 ["15"] = UDim2.new(0.02025, 0,1),
	 ["14"] = UDim2.new(0.0189, 0,1),
	 ["13"] = UDim2.new(0.01755, 0,1),
	 ["12"] = UDim2.new(0.0162, 0,1),
	 ["11"] = UDim2.new(0.01485, 0,1),
	 ["10"] = UDim2.new(0.0135, 0,1),
	 ["9"] = UDim2.new(0.01215, 0,1),
	 ["8"] = UDim2.new(0.0108, 0,1),
	 ["7"] = UDim2.new(0.0945, 0,1),
	 ["6"] = UDim2.new(0.0081, 0,1),
	 ["5"] = UDim2.new(0.00675, 0,1),
	 ["4"] = UDim2.new(0.0054, 0,1),
	 ["3"] = UDim2.new(0.00405, 0,1),
	 ["2"] = UDim2.new(0.0027, 0,1),
	 ["1"] = UDim2.new(0.00135, 0,1),
     ["0"] = UDim2.new(0, 0,1),

}
wait(2)
for i, v in pairs(HeathNums) do
	script.Parent.Size = v

	game.Players.LocalPlayer.PlayerGui.ScreenGui.UpperBars.HealthDisplay = i.."/100"
	wait(.1)
end

Okay, it’s hurting my eyes, is thsi a LocalScript? It has to

I’m so so sorry. Yes this is Localscript. I don’t know how to make something like this decently.

Can you explain what the point of this local script is?

It’s an incomplete health bar system. Each value in the table is a size that corresponds to a health number. Currently all I want is to make it slowly go from 100 → 1. I know this is unrelated to the post’s question, but is there anything I can do to make it not look so terrible?

Are you making a custom health bar for the player? like a custom health gui.

Yes, that’s what this is for. It’s a GUI bar on screen

I made it the way I did so that later on in development I can have the health set to whatever value needed at any time, because this game is going to be kind of like a dungeon crawler.

can you show me the part where you have the health bar. i’m rewriting the script rn

Like a screenshot of where it is in the Explorer?

Yes. a screenshot of it in explorer