if car.HumanoidRootPart.Velocity.Y < 0 then car.HumanoidRootPart.Velocity.Y = 0 end
So I was using this script in my game to stop it from going under 0 randomly but then this error happened.
09:28:51.474 - Y cannot be assigned to 09:28:51.476 - Script 'Players.Player.Backpack.LocalScript', Line 44 09:28:51.477 - Stack End
how would I fix this?
Thanks, KIheros
You can't set properties of classes that are not Instances
Perhaps try this instead, which will set the Y velocity to 0 when it's lower.
local vel = car.HumanoidRootPart.Velocity if vel.Y < 0 then car.HumanoidRootPart.Velocity = Vector3.new(vel.x,0,vel.z); end
Use the Changed event to detect changes in any property an object. http://wiki.roblox.com/index.php?title=API:Class/Instance/Changed
local part = car.HumanoidRootPart part .Changed:connect( function(property) if property == 'Velocity' then --If the Velocity property was changed then if part.Velocity.Y < 0 then --If Velocity.Y is less than 0 part.Velocity = Vector3.new(property.X,0,property.Z) --Create a new Vector3 for Velocity, retaining its X and Z values while making Y be 0. end end end )