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

How would you make a base position saving script?

So I don't know what to do at all. I have a folder of all the placed items for that player. I want to make it so when they leave and rejoin the placed models/buildings are still their and in the same position as when you left.

1 answer

I've done this before, and it works like a charm.

What i do is loop over each block and save the x,y,z position & rotation as such:

local basedata = {}
for _,v in pairs(base:GetChildren()) do
	local tab = {
		v.Name,
		v.Position.X, -- You might want to add base-offset to this if you build on bases instead of a free world.
		v.Position.Y,
		v.Position.Z,
		v.Rotation.X,
		v.Rotation.Y,
		v.Rotation.Z
	}
	table.insert(basedata,tab)
end

DS:SetAsync("Basedata",basedata)

For loading you then clone the block with the specific name (tab[1]), and set it's CFrame to

CFrame.new(Vector3.new(tab[2],tab[3],tab[4])) * CFrame.Angles(math.rad(tab[5]),math.rad(tab[6]),math.rad(tab[7]))

2 comments

0

still need a little help on loading the models back into the game

0

I litheraly put that in the bottom.

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