Hello, I’m currently struggling with an issue with a rig, I’ve tried to do some general scripting and then ran into the issue of when the player types with W, A, S or D it makes them endlessly glide off into the distance ending up as a huge mess.
If this doesnt fit this topic please guide me in the right direction<3
local character = script.Parent
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
for _, part in pairs(character:GetDescendants()) do
if part:IsA("MeshPart") or part:IsA("BasePart") then
part.CustomPhysicalProperties = PhysicalProperties.new(
1,
1.5,
0,
1,
1
)
end
end
local RunService = game:GetService("RunService")
RunService.Heartbeat:Connect(function()
local moveDirection = humanoid.MoveDirection
local velocity = humanoidRootPart.AssemblyLinearVelocity
if moveDirection.Magnitude < 0.1 then
humanoidRootPart.AssemblyLinearVelocity = Vector3.new(
velocity.X * 0.5,
velocity.Y,
velocity.Z * 0.5
)
else
local maxSpeed = humanoid.WalkSpeed
local horizontalVelocity = Vector3.new(velocity.X, 0, velocity.Z)
if horizontalVelocity.Magnitude > maxSpeed then
local normalized = horizontalVelocity.Unit
humanoidRootPart.AssemblyLinearVelocity = Vector3.new(
normalized.X * maxSpeed,
velocity.Y,
normalized.Z * maxSpeed
)
end
end
end)
