Hello! I’m making a game about little RC boats, and I’m having some difficulty getting them to move around. I’ve spent the last hour or so trying to figure out how to simultaneously use LookVector to move the little boat forward and adjust the rotation of the boat with CFrame.Angles.
Here’s what I’ve got now. I’ve done quite a bit of scrapping as nothing seems to work, and this doesn’t work either. The Output window is giving me "invalid argument to #1 (Vector3 expected, got CFrame)
local primary = script.Parent.PrimaryPart
while wait(0.1) do --Tick speed
script.Parent:SetPrimaryPartCFrame(
CFrame.new(primary.CFrame*CFrame.new(0,script.Parent.Speed.Value,0))
)
end
Help is very appreciated, and I still have no idea how to tackle rotation.
local primary = script.Parent.PrimaryPart
while wait(0.1) do --Tick speed
script.Parent:SetPrimaryPartCFrame(
primary.CFrame*CFrame.new(0,script.Parent.Speed.Value,0)
)
end
Thank you! The script worked first-try, although I had to move the Speed.Value over to the Z axis and make it negative. Now I’m working on a system for rotating the ship. I guess I’m just bad at CFrame or misunderstanding, because now it teleports under the map whenever I start the game. How do I use CFrame.Angles to rotate the ship?
local primary = script.Parent.PrimaryPart
while wait(0.1) do --Tick speed
script.Parent:SetPrimaryPartCFrame(
primary.CFrame*CFrame.new(0,0,-script.Parent.Speed.Value)
)
script.Parent:SetPrimaryPartCFrame(
primary.CFrame.Rotation * CFrame.Angles(0, script.Parent.Rotation.Value, 0)
)
end
Update: After some digging, I found this solution for anyone interested:
local primary = script.Parent.PrimaryPart
while wait(0.1) do --Tick speed
script.Parent:SetPrimaryPartCFrame(
primary.CFrame*CFrame.new(0,0,-script.Parent.Speed.Value)
)
script.Parent:SetPrimaryPartCFrame(
primary.CFrame * CFrame.Angles(0,math.rad(script.Parent.Rotation.Value),0)
)
end
I ended up just using a second SetPrimaryPartCFrame. I think I still need to learn more about CFrame, since the multiplication symbol seems to mean a lot while not being directly described by any built-in ROBLOX tutorial system. Weird.
Anyways, that’s how it ended.