I made a script that lets the player mine blocks, but I’m having an issue with showing up the progress bar and the rest of the GUI. Basically, I intentionally left out a GUI Folder so that one can be made, but the script still will give me the same error that GUI does not exist even though I put an
elseif not GUI.
12:56:07.950 GUI is not a valid member of Part "Workspace.Red_Mineral" - Server -
Here is the script in question, and I have marked the part that has the elseif not in it.
local tool = script.Parent local toolDamage = tool:GetAttribute("Damage") local guiElements = tool:WaitForChild("GUI") local remote = tool:WaitForChild("RemoteEvent") remote.OnServerEvent:Connect(function(player, char, mineral) toolDamage = tool:GetAttribute("Damage") if mineral.GUI and mineral:GetAttribute("Health") then local maxHealth = mineral:GetAttribute("MaxHealth") local health = mineral:GetAttribute("Health") mineral:SetAttribute("Health", health - toolDamage) mineral.GUI:WaitForChild("ProgressBar").Size = UDim2.new(health/maxHealth, 0, 0, 0) elseif not mineral.GUI and mineral:GetAttribute("Health") then -- <-- for i, v in pairs(guiElements:GetChildren()) do local guiClone = v:Clone() guiClone.Parent = mineral for ii, vv in pairs(guiClone:GetChildren()) do vv.BackgroundTransparency = 0 vv.TextTransparency = 0 end end end end)