How to get a relative coordinate

Base your code on the sample code I sent a couple of messages ago

I will do so.

Sorry for asking a lot of questions, iā€™m new with the CFrame theory so this is all a bit new.

Okay, it was a simple fix.

local newposition = position + playerroot.CFrame.RightVector

I believe you should be using LookVector for the newposition

Apparently not. I tried LookVector and it broke it, so RightVector is the solution I think.

Wait a second no, there are problems with this.

Oh?

I believe LookVector should be the correct thing in this case. What was the issue that you encountered?

Wait, now it broke completely. Using two scripts is complicated sometimes.

Iā€™ll fix it and get it to the original point, then iā€™ll show you what the problem is.

Okay, I think I made a working solution now.

So now it works pretty well. The van always comes 7 studs forward and 50 studs behind. Now I just have to make the if statement more accurate.

right now, itā€™s like this:

if math.abs(sidedoor.CFrame.X - playerroot.CFrame.X) < 0.5 then

This causes some problems, when the player root is at an angle. the problem is that the van doesnt stop exactly at the side door.

How would you change the if statement so it would use the Rightvector magic that you taught me?

You shouldnā€™t need to do that. Just check if the tween finishes playing using

TWEEN.Completed:Wait() 

or

TWEEN.Completed:Once(function()
 -- Code
end)

edit: Iā€™m going to bed now (itā€™s 1am). Someone else will be able to help if you have any issues, otherwise Iā€™ll be on in about 8 hours and can help then

1 Like

Hmm, yes this would seem like a better solution.

right now, its in a while task.wait() do loop, which I donā€™t need anymore if I can just stop the tween etc.

Iā€™ll show you the result once I get it to function.

Okay, I couldnā€™t upload the video as it is too large, but now it works flawlessy.

Thank you very much for your help and patience :+1:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.