Moving Part with W A S D without a humanoid

  1. What do you want to achieve? I want to make a part move with W A S D, however, how shall I do it without a humanoid?

  2. What is the issue? I simply don’t know how to.

  3. What solutions have you tried so far? I tried velocity and it didn’t seem to work.

Ok, so how do I add a custom move to a non-humanoid part? The main problem I am having is with jump. I also don’t want to use velocity because I want to control anchored parts, without un-anchoring them. Should I use CFrame?

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local LP = Players.LocalPlayer
local mouse = LP:GetMouse()
local camera = workspace.CurrentCamera

local part = Instance.new("Part",workspace)
part.CFrame = CFrame.new(0,2,0)
part.Anchored = true

local down = {
	W = false,
	S = false
}

mouse.KeyDown:Connect(function(key)
	key = string.lower(key)
	if key == "w" then
		down.W = true
	elseif key == "s" then
		down.S = true
	end
end)

mouse.KeyUp:Connect(function(key)
	key = string.lower(key)
	if key == "w" then
		down.W = false
	elseif key == "s" then
		down.S = false
	end
end)


RunService.RenderStepped:Connect(function()
	camera.CameraSubject = part
	camera.CameraType = Enum.CameraType.Attach
	
	local move = CFrame.new(0,0,0)
	if down.W == true then
		move = move * CFrame.new(0,0,-1)
	end
	if down.S == true then
		move = move * CFrame.new(0,0,1)
	end
	part.CFrame = part.CFrame * move
	
end)

There are a couple problems with. First of all, the camera doesn’t keep up with the part. The main problem is, how do I make it jump? With gravity?

1 Like

Use VectorForce to move the part and CFrame to move the camera

Will this work with anchored parts though?