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

Can you make a part move using WASD?

Asked by 6 years ago
Edited 6 years ago

In the game, I'm trying to make it so that when you sit in a certain seat a GUI will pop up and some controls. I know how to do that, but when you select the part you want to move in the GUI I'm not sure how to make the player be able to move the part using WASD. I was thinking about using Key-down and C frame, But i'm still new to scripting so I wanted to ask just in case its not possible. Anyone know how to do this??

This how I thought to start it,

local part = script.parent

function onKeyPress(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.W then part.Cframe.new --Thats as far as I can get so far end end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

1 answer

Log in to vote
0
Answered by 6 years ago

Increase the CFrame by 1 depending on which dimension you're increasing, so it'd end up like:

function onKeyPress(inputObject, gameProcessedEvent)
 if inputObject.KeyCode == Enum.KeyCode.W then 
part.CFrame = part.CFrame + Vector3.new(x,y,z) -- if increasing x by 1 it would be 1,0,0 and so forth
end
end
game:GetService("UserInputService").InputBegan:connect(onKeyPress) 
0
If you want the brick to move faster/farther then increase the dimension's value higher, ultrasonicboomer 85 — 6y
Ad

Answer this question