RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a script that lets you control a model using the WASD keys"
-- local script local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local model = game.Workspace.Model local moveSpeed = 10 local function moveModel(direction) model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame * CFrame.new(direction * moveSpeed)) end local function handleKeyPress(input) local inputKey = input.KeyCode if inputKey == Enum.KeyCode.W then moveModel(Vector3.new(0, 0, -1)) elseif inputKey == Enum.KeyCode.A then moveModel(Vector3.new(-1, 0, 0)) elseif inputKey == Enum.KeyCode.S then moveModel(Vector3.new(0, 0, 1)) elseif inputKey == Enum.KeyCode.D then moveModel(Vector3.new(1, 0, 0)) end end game:GetService("UserInputService").InputBegan:Connect(handleKeyPress)