I really don't know how to reference the velocity in ROBLOX Lua coding. This is my block of code;
if script.Parent.Velocity == 75 then script.Parent:breakJoints()
I first thought that just saying "Velocity" was gonna work, but it doesn't. Any suggestions?
local BREAK_VELOCITY = 10 if Part.Velocity.Magnitude >= BREAK_VELOCITY then Humanoid:BreakJoints() end
EDIT: Nevermind, you cannot use GetPropertyChangedSignal on velocity
ANSWER: You will use GetPropertyChangedSignal
local part -- This must be set to the primary part of the object you wish to check the velocity for part:GetPropertyChangedSignal("Velocity"):Connect(function() if part.Velocity >= 75 then --break joints end end)
for convenience, we're going to make a variable for the max velocity, called "MAX" i also had this problem when i started,but i figured it out, there's a hidden value to "velocity" called magnitude that is pretty much the general speed (in SPS) that the part is moving at
we can add .Magnitude after Velocity to use that, which should make it work properly
local MAX = 75 -- the value at which the joints break if script.Parent.Velocity.Magnitude >= MAX then --checking if the speed of the part is greater or equal to max (using == might not work since sometimes the part can skip the target because its going too fast) script.Parent:breakJoints() -- breaking the joints in the part end
hope this helped you out!