Does the just move at the same speed after?
Yeah, pretty much. I don’t think anchoring parts gets rid of the velocity unfortunately.
Try setting the humanoid’s walk speed to 0.
then back to normal walk speed
You need to wait until physics have finished simulating for that frame (with heartbeat) and then set the velocity to 0
game:GetService'RunService'.Heartbeat:Wait()
plr.Character.PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
Don’t really think that’s doing anything
I’m kind of new to scripting, what does this line do?
game:GetService'RunService'.Heartbeat:Wait()
It wait until after the game has finished calculating physics for that frame
Here is a good explanation:
Thanks for sending me that post. I’ve integrated your suggestion into my script, but it still doesn’t seem to be working properly. Did I put it in correctly?
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
local Humanoid = plr.Character:WaitForChild("Humanoid")
Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
if Humanoid.MoveDirection == Vector3.new(0, 0, 0) then
print("Setting velocity to 0")
game:GetService"RunService".Heartbeat:Wait()
Humanoid.Parent.PrimaryPart.AssemblyLinearVelocity = Vector3.new()
end
end)
end)
end)
On the line after the wait for heartbeat, it says
Vector3.new()
Try
Vector3.new(0, 0, 0)
Seems to work fine for me.
Is your script a server script or a localscript?
Server script under ServerScriptService
On the line after the wait for heartbeat, it says
Vector3.new()
Try
Vector3.new(0, 0, 0)
Try this. If this doesn’t work I have one more idea.
Vector3.new()
automatically constructs a vector with 0,0,0 coords if no args are passed
I just put the script into a blank game, and it works
Ok, the script works in a default baseplate, but not my actual game. I’ll have to do some looking to make sure I don’t have some weird setting enabled. Anyways, thanks for both of you guy’s help.
I found the issue. My game was using R6 character models which use the head as the Primary Part, but you need to apply the velocity to the HumanoidRootPart.
Which meant that maybe if you tried my anchor method, it would work aswell.
When you anchor a part, the velocity still resumes, anchoring doesnt work
Its odd cause this worked for me in the past.