I'm a beginner to coding and I'm trying to make a Health Bar script like the one below:
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() local Human = Character:WaitForChild("Humanoid") local HealthFrame = script.Parent Human.HealthChanged:Connect(function(Health) HealthFrame.Size = UDim2.new(HealthFrame/Human.MaxHealth,0,1,0) end)
But then I get an error like this:
Players.Klydefiss.PlayerGui.HealthStaminaUI.OuterFrame.HealthFrame.HealthBar.HealthScript:7: attempt to perform arithmetic on upvalue 'HealthFrame' (a userdata value)
I don't understand what arithmetic or upvalue means, So it would be nice if someone could explain to me what this error means.
Human.HealthChanged:Connect(function(Health) HealthFrame.Size = UDim2.new(HealthFrame.Position.Scale.X/Human.MaxHealth,0,1,0) end)