So basically, I’ve set the walkspeed of my game to 2000, but I’ve found that now it takes the player a few seconds to come to a complete stop after releasing their w key. I want the player to come to an instant stop, so I tried setting their HumanoidRootPart’s AssemblyLinearVelocity to 0 every time they stopped trying to move, but it didn’t work. What should I do instead?
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("Set the velocity to 0")
plr.Character.PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
end
end)
end)
end)
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("Set the velocity to 0")
plr.Character.PrimaryPart.Anchored = true
wait(0.1)
plr.Character.PrimaryPart.Anchored = false
end
end)
end)
end)
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)