Need help with assinging positions using a table

I want to assign a part positions using a table, i’ve tried mutiple things and nothing has worked yet. I have looked for solutions on the dev forum. Can someone help me out :smiley:

Here is the error…

-- local indicatorsPos = {
	["pos1"] = {22813.625, 1059.75, 2973.25}
}

function module.CreateTask ()
	local CreateNewIndicatorTarget = IndicatorTarget:Clone()
	CreateNewIndicatorTarget.Parent = game.Workspace.RophoraPos
	CreateNewIndicatorTarget.CFrame = indicatorsPos[math.random(1)]
	
	
	local FindTask = rophoraTasks[math.random(1, #rophoraTasks)]
	player.PlayerGui.MainGui.Frame.TextLabel.Text = "Task:\t"..FindTask
end

You didn’t set a CFrame, also, I don’t think you need to use CFrame here either

CreateNewIndicatorTarget.CFrame = indicatorsPos[math.random(1)]

Change the above code to

CreateNewIndicatorTarget.Position = Vector3.new(indicatorsPos[math.random(1)])

For some reason, it spawns at center of baseplate and does not spawn at assigned location.
image


local indicatorsPos = {
	["pos1"] = {46, 0.1, 60}
}

function module.CreateTask ()
	local CreateNewIndicatorTarget = IndicatorTarget:Clone()
	CreateNewIndicatorTarget.Parent = game.Workspace.RophoraPos
	CreateNewIndicatorTarget.Position = Vector3.new(indicatorsPos[math.random(1)])
	
	
	local FindTask = rophoraTasks[math.random(1, #rophoraTasks)]
	player.PlayerGui.MainGui.Frame.TextLabel.Text = "Task:\t"..FindTask
end

Sorry, took a bit to figure out,

change this

CreateNewIndicatorTarget.Position = Vector3.new(indicatorsPos[math.random(1)])

to this

local ranNumb = math.random(1)
CreateNewIndicatorTarget.Position = Vector3.new(indicatorsPos[1].x,indicatorsPos[1].y,indicatorsPos[1].z)

also change the table to this

local indicatorsPos = {
	[1] = {[x]=46, [y]=0.1, [z]=60}
}

It kept cloning at 0,0,0 because if you print indicatorsPos[1] you’d get
[1]= number
[2]= number
[3]= number
and you can’t assign the table values as vector values

local indicatorsPos = {
    --I recommend using arrays here so you can easily find random numbers using math.random
	[1] = CFrame.new(22813.625, 1059.75, 2973.25) --this must be a CFrame value
}

function module.CreateTask()
	local CreateNewIndicatorTarget = IndicatorTarget:Clone()
	CreateNewIndicatorTarget.Parent = game.Workspace.RophoraPos

    --math random needs a max value, just a 1 will always return 1
    --With an array table, we can easily get the table length to use in math.random
    local randomPos = indicatorsPos[math.random(1, #indicatorPos]] 
	CreateNewIndicatorTarget.CFrame = randomPos
	
	--Infact, you use the exact same method here!
	local FindTask = rophoraTasks[math.random(1, #rophoraTasks)]
	player.PlayerGui.MainGui.Frame.TextLabel.Text = "Task:\t"..FindTask
end