RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"15:46:01.730 Head is not a valid member of Model "Workspace.qw3rty_l0l" - Client - Oxygen:4"
-- It seems like the script is trying to access the 'Head' part of the character model which does not exist or is not named as 'Head'. You can use the FindFirstChild method to ensure the 'Head' part exists before accessing it. local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:FindFirstChildWhichIsA("Humanoid") local head = character:FindFirstChild("Head") -- use FindFirstChild to ensure 'Head' exists if not head then return -- if 'Head' does not exist, stop executing the script end local oxygenBar1 = player.PlayerGui:WaitForChild("Oxygen") local oxygenBar = oxygenBar1:WaitForChild("Bar") local healthDecreaseRate = 10 local oxygenDecreaseRate = 1 local oxygenIncreaseRate = 2 local isHeadInWater = false while task.wait() do local headPos = head.Position local partsInRegion = workspace:FindPartsInRegion3(Region3.new(headPos - Vector3.new(1,1,1), headPos Vector3.new(1,1,1)), nil, math.huge) for i, part in ipairs(partsInRegion) do if part.Name == "Water" then isHeadInWater = true break else isHeadInWater = false end end if isHeadInWater then if oxygenBar.Size.X.Scale > 0 then oxygenBar.Size = UDim2.new(oxygenBar.Size.X.Scale - oxygenDecreaseRate, 0, 1, 0) else if humanoid.Health > 0 then humanoid.Health = humanoid.Health - healthDecreaseRate end end else if oxygenBar.Size.X.Scale < 1 then oxygenBar.Size = UDim2.new(oxygenBar.Size.X.Scale oxygenIncreaseRate, 0, 1, 0) end end end