Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How would you make a base position saving script?

Asked by 7 years ago

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

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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]))
0
still need a little help on loading the models back into the game Bylocks 1 — 7y
0
I litheraly put that in the bottom. RubenKan 3615 — 7y
Ad

Answer this question