Hello I am currently working on a mounting system, what my script does is basically receive the input key the player is pressing and based on that, choose the direction the mount is supposed to go, then send it to the server using a remote event and the serverscript makes the mount’s humanoid MoveTo the position.
the problem is when I test it, it just started rotating randomly
here is my local script:
local movements = {
forward = Enum.KeyCode.W,
left = Enum.KeyCode.A,
right = Enum.KeyCode.S,
back = Enum.KeyCode.D,
up = Enum.KeyCode.Space--will be used for later
}
local function getforwardpos(part)
return part.CFrame + part.CFrame.LookVector * 100
end
local function getrightpos(part)
return part.CFrame + part.CFrame.RightVector * 100
end
local function getleftpos(part)
return part.CFrame + -part.CFrame.RightVector * 100
end
UIS.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then--going to add mobile and xbox support after I get this figured out
local keyPressed = input.KeyCode
print(keyPressed)
if keyPressed == movements.forward then
game.ReplicatedStorage.MoveRide:FireServer(script.Parent.Parent.PlayerGui.Riding.Value, getforwardpos(script.Parent.Parent.PlayerGui.Riding.Value:FindFirstChild("HumanoidRootPart")))
elseif keyPressed == movements.left then
game.ReplicatedStorage.MoveRide:FireServer(script.Parent.Parent.PlayerGui.Riding.Value, getleftpos(script.Parent.Parent.PlayerGui.Riding.Value:FindFirstChild("HumanoidRootPart")))
elseif keyPressed == movements.right then
game.ReplicatedStorage.MoveRide:FireServer(script.Parent.Parent.PlayerGui.Riding.Value, getrightpos(script.Parent.Parent.PlayerGui.Riding.Value:FindFirstChild("HumanoidRootPart")))
end
end
end)