Velocity is not working in my script

Hey,

what do am I trying to achieve?
I want to put a force on my part which allows me to push it forward/backward and left/right. I have been watching some programming videos and as many other studios I have tried to but a velocity on the part.

Here is my script:


local inputs = game:GetService("UserInputService")

local phumanoid = game.Workspace.phumanoid

local camera = game.Workspace.Camera
camera.CameraSubject = phumanoid

inputs.InputBegan:Connect(function(inp)
	if inp.KeyCode == Enum.KeyCode.W then
		phumanoid.Velocity.Z += 15
	end
	if inp.KeyCode == Enum.KeyCode.S then
		phumanoid.Velocity.Z += -15
	end
	if inp.KeyCode == Enum.KeyCode.D then
		phumanoid.Velocity.X += 15
	end
	if inp.KeyCode == Enum.KeyCode.A then
		phumanoid.Velocity.X += -15
	end
end)

inputs.InputEnded:Connect(function(inp)
	if inp.KeyCode == Enum.KeyCode.W then
		phumanoid.Velocity.Z += 0
	end
	if inp.KeyCode == Enum.KeyCode.S then
		phumanoid.Velocity.Z += 0
	end
	if inp.KeyCode == Enum.KeyCode.D then
		phumanoid.Velocity.X += 0
	end
	if inp.KeyCode == Enum.KeyCode.A then
		phumanoid.Velocity.X += 0
	end
end)

So the idea is to let a part glide on the baseplate.

I mean the script explains everything so what have I been programming wrong?

Try using the Vector3.new() method instead of adding on the axis:

for example here

Instead:

phumanoid.Velocity = Vector3.new(phumanoid.Velocity.X,phumanoid.Velocity.Y,phumanoid.Velocity.Z + 15) 

Okey it sounds like good but what should I use for InputEnded?

And also it doesnt work I tested it out :confused:

Maye becuase it’s a local script. Also did u put the local scrript in starter player script or starter gui? Also is it a local script?

yes still doesnt work I dont now why Roblox Studio api doesnt have “Velocity”

Just look at minit 6.54 in the video