#how to make invariable walkspeed
11 messages · Page 1 of 1 (latest)
function Movement(player, humanoid:Humanoid, keys, cameracframe:CFrame)
local x, z = 0, 0
local lv = cameracframe.LookVector.Unit
local rd = cameracframe.RightVector.Unit
if keys["W"] == true then
x += lv.X
z += lv.Z
end
if keys["S"] == true then
x -= lv.X
z -= lv.Z
end
if keys["A"] == true then
x -= rd.X
z -= rd.Z
end
if keys["D"] == true then
x += rd.X
z += rd.Z
end
local tweenInfo = TweenInfo.new(
0.05,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out
)
local tweenGoal = {Position = humanoid.Parent.HumanoidRootPart.Position + Vector3.new(x, 0, z)}
local tween = game:GetService("TweenService"):Create(humanoid.Parent.HumanoidRootPart, tweenInfo, tweenGoal)
tween:Play()
humanoid.Parent:PivotTo(CFrame.new(humanoid.Parent:GetPivot().Position, humanoid.Parent:GetPivot().Position +
Vector3.new(cameracframe.LookVector.X,0,cameracframe.LookVector.Z)))
end
uhh, damn
try using runservice or find a way to detect change
and then when it does
just set the x and z thingy to the value you want
when I try to add the y to both x,z for both lv and rd it expontentially increases each time the function is fired and messes up the movement