lately ive been trying to make a script that just flies you depending on what keybinds you use. i decided to use humanoid.movedirection so that its compatible with mobile, yet… when i face the right direction my movement slows down DRASTICALLY and thats not what i really intended.
heres the script (that took embarrasingly long to make, for something that doesnt even work properly.):
local cameracf = game.ReplicatedStorage.remoteevents.giveservercameracframe:InvokeClient(plr)
local hummy = plr.Character:FindFirstChildOfClass("Humanoid")
local X, Y, Z = cameracf:ToEulerAnglesYXZ()
plr.Character:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(plr.Character:FindFirstChild("HumanoidRootPart").Position) * CFrame.Angles(0, Y, 0) + Vector3.new((hummy.MoveDirection.X * math.abs(math.deg(Y))/360)*4, (math.deg(X)/360)*4, (hummy.MoveDirection.Z * math.abs(math.deg(Y))/360)*4)
task.wait()
local plr = game:GetService("Players").LocalPlayer
local HumanoidRootPart:Part = plr.Character:WaitForChild("HumanoidRootPart")
local hummy = plr.Character:FindFirstChildOfClass("Humanoid")
local RunService = game:GetService("RunService")
local Camera = workspace.CurrentCamera
RunService.RenderStepped:Connect(function()
local X, Y, Z = Camera.CFrame:ToEulerAnglesYXZ()
HumanoidRootPart.CFrame = CFrame.new(HumanoidRootPart.Position) * CFrame.Angles(0, Y, 0) + Vector3.new(hummy.MoveDirection.X, Camera.CFrame.LookVector.Y, hummy.MoveDirection.Z)
end)
I can’t exactly explain your bug, but i’m sure that it’s occured due to zero Y rotation.
And also you don’t need to use server script to change position, Roblox automatically replicate character’s position to server.
thanks for the reply!! not quite sure if that will work as i think ive tried it before but now i cant even trust myself after how much ive failed to make it so ill try using that code when i am able to!