-
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?
-
What is the issue? I simply don’t know how to.
-
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?