Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Can you make a part move using WASD?

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

✓ Accepted answer

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) 

1 comment

0

If you want the brick to move faster/farther then increase the dimension's value higher,

This discussion is preserved as it was. New answers, comments, and votes are closed.