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

How would i get my part to move in the direction its facing? [closed]

Asked by 2 years ago

Please provide more explanation in your question. If you explain exactly what you are trying to accomplish, it will be much easier to answer your question correctly.
local dronefacing

function droneMovement(player,keypressed,direction)
    if keypressed == "w" then
        Bodypos.Position = Bodypos.Position + Vector3.new(0,0,-1)


    elseif keypressed == "a" then
        Bodypos.Position = Bodypos.Position + Vector3.new(-1,0,0) 


    elseif keypressed == "s" then
        Bodypos.Position = Bodypos.Position + Vector3.new(0,0,1) 

    elseif  keypressed == "d" then
        Bodypos.Position = Bodypos.Position + Vector3.new(1,0,0)



    end


    if direction == "Right" then
        drone.CFrame = CFrame.new(Bodypos.Position, CFrame.Angles(math.rad(1,0,0)))  
    end

    if direction == "Left" then
        drone.CFrame =   CFrame.new(Bodypos.Position, CFrame.Angles(0,0,math.rad(-1)))
    end

    local dronefacing = drone.CFrame.LookVector




end



droneserver.OnServerEvent:Connect(droneMovement)

Closed as Non-Descriptive by JesseSong

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?

1 answer

Log in to vote
0
Answered by 2 years ago

I recommend using LookVector, RightVector or UpVector https://scriptinghelpers.org/questions/14747/what-is-lookvector-and-how-do-i-use-it

0
Yes ik but is it better to use in the if direction statement or the if keypressed statement? chuba143 -3 — 2y
Ad