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)
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)