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

How to save model positions?

On line 7 it prints -18.929458618164

Im getting this error on line 8 but im not sure what to do or what it means.

-18.929458618164 is not a valid member of Folder

Remote Function script

local ItemStore = game:GetService("DataStoreService"):GetDataStore("Items")

game.Players.PlayerAdded:connect(function(player)
local objects = ItemStore:GetAsync("Details" .. player.Name) or {}
if objects ~= nil then
for i = #objects, 1, -1 do
    print(objects[1])   
    local Item = game.ServerStorage.Items[objects[i-3]]:Clone()
    local coord1 = objects[i-2]
    local coord2 = objects[i-1]
    local coord3 = objects[i]
    Item:SetPrimaryPartCFrame(CFrame.new(coord1,coord2,coord2))
    Item.Parent = game.Workspace
   	 end
	end
end)

local function Saving(player, PositionX, PositionY, PositionZ)
	local objects = ItemStore:GetAsync("Details" .. player.Name) or {}
	print(PositionX)
	print(PositionY)
	print(PositionZ)
    local findItems = workspace.Placed:GetChildren()
    for i = #findItems, 1, -1 do
    table.insert(objects,i-2,tostring(findItems[i].PrimaryPart.Position.X))
    table.insert(objects,i-1,tostring(findItems[i].PrimaryPart.Position.Y))
    table.insert(objects,i,tostring(findItems[i].PrimaryPart.Position.Z))
    end
    ItemStore:SetAsync("Details" .. player.Name, objects)
end

game.ReplicatedStorage.Saving.OnServerInvoke = Saving

Gui Script

script.Parent.MouseButton1Click:connect(function()
    local findItems = workspace.Placed:GetChildren()
    for i = #findItems, 1, -1 do
	game.ReplicatedStorage.Saving:InvokeServer(findItems[i].PrimaryPart.Position.X, findItems[i].PrimaryPart.Position.Y, findItems[i].PrimaryPart.Position.Z)
    end
end)

1 answer

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