Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make brick move off of camera's rotation?

Asked by 3 years ago

I'm working on an old roblox simulator that has a built in studio and I'm currently trying to make the system for moving around. I'm trying to use the camera's look vector + the humanoidrootpart's CFrame to get it to move since I need to have it anchored which means I can't use velocity (If it's unanchored the rotation gets all wonky which makes the camera wobble a lot, and if I set gravity to 0, it still doesnt work)

Here's what I have so far:

local cam = game.Workspace.CurrentCamera
local UserInputService = game:GetService("UserInputService")
local plr = script.Parent

while wait(0.01) do
    local pos = plr.HumanoidRootPart.CFrame
    if UserInputService:IsKeyDown(Enum.KeyCode.W) then
        print("moving forward")
        pos = pos+cam.CFrame.LookVector*5
    end
end

Answer this question