I'm trying to make a boat to move using Vector3 and there isn't very much info in regards to using NormalId. Is there a way to make this work or is there a better solution?

local UIS = game:GetService("UserInputService")
local seat = script.Parent
local gyro = seat.BodyGyro
local pos = seat.BodyPosition
local vel = seat.BodyVelocity
local occupant = seat.Occupant
local IsOccupied = false

UIS.InputBegan:connect(function(input)
	if IsOccupied == true then
		if input.KeyCode == Enum.KeyCode.W then
			seat.Anchored = false
			vel.Velocity = Vector3.FromNormalId(Enum.NormalId.Front) -- These make it move very slowly
			
		elseif input.KeyCode == Enum.KeyCode.A then
			seat.Anchored = false
			vel.Velocity = Vector3.FromNormalId(Enum.NormalId.Left)
				
		elseif input.KeyCode == Enum.KeyCode.S then
				seat.Anchored = false
			vel.Velocity = Vector3.FromNormalId(Enum.NormalId.Back)
			
		elseif input.KeyCode == Enum.KeyCode.D then
			seat.Anchored = false
		vel.Velocity = Vector3.FromNormalId(Enum.NormalId.Right)
			
		end		
	end
end)

Thanks for the help!

7 comments

0

Is your script a localscript or server script?

0

It is a server script, when I tried porting it to a local script it didn't work at all

0

UserInputService doesn’t exist on the server. You should handle user input on LocalScripts only.

0

Alright, however the problem here is that the boat won't move very far. Do you know how NormalId works?

0

Gonna base this from "http://wiki.roblox.com/index.php?title=API:Vector3" but all you're doing is applying a unit vector(vector w/ magnitude 1) to the velocity. In effect, you're just making it move at a snail's pace. To make it move faster, consider multiplying the vector by a constant like 100 or something.

0

To give you a direction on how to address your non-axis direction problem, consider using InputEnd (not sure of the actual name) for UserInput Service. Register all keys being held down w/ InputBegan and recalculate the velocity based on the keys being held. Use InputEnd to get rid of the key being held down, and recalculate the velocity.

0

Alright, thanks for the help!