My part is not moving in a diagonal direction when two buttons are pressed at the same time?
01 | function droneMovement(player,keypressed,direction) |
02 | local dronecframe = drone.CFrame |
04 | if keypressed = = "w" then |
05 | Bodypos.Position = dronecframe:PointToWorldSpace(Vector 3. new( 0 , 0 ,- 3 )) |
08 | elseif keypressed = = "a" then |
09 | Bodypos.Position = dronecframe:PointToWorldSpace(Vector 3. new(- 3 , 0 , 0 )) |
12 | elseif keypressed = = "s" then |
13 | Bodypos.Position = dronecframe:PointToWorldSpace(Vector 3. new( 0 , 0 , 3 )) |
15 | elseif keypressed = = "d" then |
16 | Bodypos.Position = dronecframe:PointToWorldSpace(Vector 3. new( 3 , 0 , 0 )) |
21 | if direction = = "Right" then |
22 | BodyGyro.CFrame = BodyGyro.CFrame * CFrame.new(Bodypos.Position) * CFrame.Angles( 0 ,math.rad(- 2.5 ), 0 ) |
25 | if direction = = "Left" then |
26 | BodyGyro.CFrame = BodyGyro.CFrame * CFrame.new(Bodypos.Position) * CFrame.Angles( 0 ,math.rad( 2.5 ), 0 ) |
35 | droneserver.OnServerEvent:Connect(droneMovement) |
thats the ^ server script where everything moves in the server
01 | function drone.dronemovement() |
04 | droneserver:FireServer( "w" ) |
07 | droneserver:FireServer( "a" ) |
10 | droneserver:FireServer( "s" ) |
14 | droneserver:FireServer( "d" ) |
22 | local arr = userinputservice:GetKeysPressed() |
24 | for _,key in pairs (arr) do |
26 | local check = validKeys [ key.KeyCode.Name ] |
This is the module script where i am trying to get the part to move when in a diagonal direction when when for example W+A is pressed at the same time on the keyboard.