Ok guys, I'm a bit new to Lua so I might not see obvious things you do
My problem is that I'm currently trying to find out (in my game) how much percentage of throttle is the player on. The thing is, my equation always return 'inf' for some reason and I could only assume my equation was too heavy
Here's my equation to find out the percentage of throttle: X / Y * 100
Script:
wait() local Player = script.Parent.Parent.Parent -- Player in the 'Players' folder local Force = workspace[Player.Name].HumanoidRootPart.VectorForce -- The force inside of the player local ThrottleIndicator = script.Parent.ThrottleIndicator -- The player's throttle indicator local InputService = game:GetService("UserInputService") local MaxForce = script.Parent:WaitForChild("PlayerMaxForce") local ThrottlePercentageDisplayable = Force.Force.Y / MaxForce.Value * 100 ThrottleIndicator.Text = ThrottlePercentageDisplayable.."%" print(ThrottleIndicator.Text)
Just observe the last three lines
I can confirm that Force.Force.Y is not 0 and MaxForce.Value is not 0
I tried breaking up the equation into two variables. One did the multiplication and then the other did division and I still got inf
How could I do the math so that Lua doesn't give me inf?
Oh yes, and another weird thing, if I put the same equation into the command bar (I took the numbers of Force.Force.Y and MaxForce.Value) and I enter the equation, it works COMPLETELY FINE!