Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to save a part's position according to another part's position?

Well.. I am working on a type of sandbox game. Let's say I want to save a part's position. I can't just save where it's located because if the player rejoins and has a new baseplate location. The part will then spawn some where else. I need it to spawn on the player's baseplate.

How would I perform this? I am not asking for the script, it'd be helpful if you provide an idea or a piece of code.

1 answer

✓ Accepted answer

You can try saving the model CFrames using CFrame:ToObjectSpace(Baseplate CFrame), at which point you can transform that back to a usable CFrame when you reload with CFrame:ToWorldSpace(newBaseplate CFrame)

Both of these methods return CFrames so in use it'd look something like:

relativeCFrame = ModelCFrame:ToObjectSpace(Baseplate CFrame)
worldCFrame = relativeCFrame:ToWorldSpace(newBaseplateCFrame)
model:SetPrimaryPartCFrame(wolrdCFrame)

These are methods of CFrame and more documentation about them can be found at CFrame Documentation

6 comments

0

edited for clarity

0

So I'd have to do game.Workspace.Part.CFrame:ToObjectSpace(Baseplate.CFrame)

0

yep, that'd be reasonable.

0

Do you have discord? I'm so confused.

0

Yep. I'll PM it to you on roblox.

0

My account is ActiveMiner. This is my old scriptinghelpers account.

This discussion is preserved as it was. New answers, comments, and votes are closed.