Attempt to concatenate Instance with string

  1. What do you want to achieve?
    Be able to get data from a specific key
    Also see that this is instance with string, not a string with instance.

  2. What is the issue?

for i ,v in ipairs(datastore:GetAsync(player.."Values")) do

This line the error is on this line, and there are ends obviously.

  1. What solutions have you tried so far?
    There weren’t topics on this so I decided to open one. I’m not sure what to try however.
1 Like
for i ,v in ipairs(datastore:GetAsync(player.Name.."Values")) do
1 Like
datastore:SetAsync(key.."Values",PlayerInfo)

This is how I’ve saved it, are you sure it will work?

1 Like

oh wait. is the key the user id?

1 Like

Yeah, I’ve put those dots to make a prefix so it still saves on the User’s id. Is there any chance it interferes with my variables?

try this

for i ,v in ipairs(datastore:GetAsync(player.UserId.."Values")) do

image

send the whole script…
\\\\\\\\

Just so you know it’s a function

local function load(player: Player)
	local key = player.UserId
	local success, err
	local data

	repeat
		success, err = pcall(function()
			data = datastore:GetAsync(key)
		end)
	until success or not players:FindFirstChild(player.Name)
	if not data then return end
	if success then
		for i, obj in ipairs(data) do
			for i ,v in ipairs(datastore:GetAsync(player.UserId.."Values")) do
				print(v[1])
				local newPart = Instance.new("Part")
				newPart.Name = obj[1]
				newPart.Size = Vector3.new(obj[2],obj[3],obj[4])
				newPart.Parent = workspace.BaseInfo.Base1
				newPart.CFrame = CFrame.new(obj[5],obj[6],obj[7])
			end

		end
	else
		print("fail", err)
	end
	script.Parent.Parent.SurfaceGui.Status.Text = "Claimed by:"..player.Name
	player.HasBase.Value = true
	player.LastBase.Value = 1
end

the entire script please I cant do much

local DataStoreS = game:GetService("DataStoreService")
local datastore = DataStoreS:GetDataStore("TestSave1")
local players = game:GetService("Players")

local function load(player: Player)
	local key = player.UserId
	local success, err
	local data

	repeat
		success, err = pcall(function()
			data = datastore:GetAsync(key)
		end)
	until success or not players:FindFirstChild(player.Name)
	if not data then return end
	if success then
		for i, obj in ipairs(data) do
			for i ,v in ipairs(datastore:GetAsync(player.UserId.."Values")) do
				print(v[1])
				local newPart = Instance.new("Part")
				newPart.Name = obj[1]
				newPart.Size = Vector3.new(obj[2],obj[3],obj[4])
				newPart.Parent = workspace.BaseInfo.Base1
				newPart.CFrame = CFrame.new(obj[5],obj[6],obj[7])
			end

		end
	else
		print("fail", err)
	end
	script.Parent.Parent.SurfaceGui.Status.Text = "Claimed by:"..player.Name
	player.HasBase.Value = true
	player.LastBase.Value = 1
end

script.Parent.MouseClick:Connect(load)

Why are you looping… Do you know anything about datastores?

Please read
Data Stores | Documentation - Roblox Creator Hub.

Well I saw a tutorial on data stores on youtube, I copied a few stuff from there, however, I’ve read datastore many times in the past. Im not sure how to get my parts to spawn in any other way.

Nvm, it was from a print line, however, I am still not sure what are the other ways to save and load arrays.

Can you send the code on how youre saving the data? The error that you named the post with means you tried to do something like this:
local string = workspace.Part.."hi"