Applying values to Positions

I’ve been trying to get values to move the part to the position and won’t do it and returns all positions and orientations as 0,0,0 even when the values are different

Section

for _, Post in pairs(Posts) do
	Post.Button.Triggered:Connect(function(player)
		for i = 1, #Posts do
			Posts[i].Anchored = true
			Posts[i].Orientation = Vector3.new(""..Posts[i].OrtX.Value.." ,"..Posts[i].OrtY.Value.." ,"..Posts[i].OrtZ.Value.."")
			Posts[i].Position = Vector3.new(Posts[i].PosX.Value..","..Posts[i].PosY.Value..","..Posts[i].PosZ.Value)
			
			Posts[i].Button.Enabled = false
		end
	end)
end

Full program

local Posts = {}
for i, v in pairs(script.Parent:GetChildren()) do if v.Name == "Post" then table.insert(Posts,v) end end -- INSERTING POSTS

for i = 1, #Posts do 
	local XYZ = script.XYZ:Clone()
	XYZ.Name = "OrtX"
	XYZ.Value = Posts[i].Orientation.X
	XYZ.Parent = Posts[i] 
	local XYZ = script.XYZ:Clone()
	XYZ.Name = "OrtY"
	XYZ.Value = Posts[i].Orientation.Y
	XYZ.Parent = Posts[i] 
	local XYZ = script.XYZ:Clone()
	XYZ.Name = "OrtZ"
	XYZ.Value = Posts[i].Orientation.Z
	XYZ.Parent = Posts[i]
	local XYZ = script.XYZ:Clone()
	
	XYZ.Name = "PosX"
	XYZ.Value = Posts[i].Position.X
	XYZ.Parent = Posts[i]
	local XYZ = script.XYZ:Clone()
	XYZ.Name = "PosY"
	XYZ.Value = Posts[i].Position.Y
	XYZ.Parent = Posts[i]
	local XYZ = script.XYZ:Clone()
	XYZ.Name = "PosZ"
	XYZ.Value = Posts[i].Position.Z
	XYZ.Parent = Posts[i]
end

for _, Post in pairs(Posts) do
	Post.Button.Triggered:Connect(function(player)
		for i = 1, #Posts do
			Posts[i].Anchored = true
			Posts[i].Orientation = Vector3.new(""..Posts[i].OrtX.Value.." ,"..Posts[i].OrtY.Value.." ,"..Posts[i].OrtZ.Value.."")
			Posts[i].Position = Vector3.new(Posts[i].PosX.Value..","..Posts[i].PosY.Value..","..Posts[i].PosZ.Value)
			
			Posts[i].Button.Enabled = false
		end
	end)
end
2 Likes

What you should do is:

Posts[i].Orientation = Vector3.new(Posts[i].OrtX.Value, Posts[i].OrtY.Value, Posts[i].OrtZ.Value)
Posts[i].Position = Vector3.new(Posts[i].PosX.Value, Posts[i].PosY.Value, Posts[i].PosZ.Value)

Don’t make it a string

(You don’t need to change it but i think it would be a better practice to use Vector3Values instead of 3 number values)

2 Likes