Lets say there are multiple objects in a workspace with the same name: item & item
They are both located under game.Workspace.Terrain.item
I want to be able to grab the position of them and set that to a variable as follows in terms of the Vector3 location
local test = game.Workspace.Terrain.item.Position
I've been able to do this with objects that are in the game as long as there is only one of them with a name that isn't being shared by another object. What I want to do currently works if there is only one item.
How do I grab and save the position of multiple items with the same name and workspace location?
My ultimate goal is to be able to split up the two items with their different vectors so I can save the coordinates as local x = item.x etc. Is there a way to maybe split the returned vectors into an array and do something like local x = item[1].x?
local parts = workspace.Terrain:GetChildren() local char = workspace:FindFirstChild(game.Players.LocalPlayer.Name) script.Parent.MouseButton1Click:Connect(function() char.HumanoidRootPart.CFrame = parts[math.random(#parts)].CFrame end)
for i,v in pairs(game.Workspace.Terrain:GetChildren()) do if v:IsA("Part") and v.Name == "Pad" then --classname and name of part local test = v.Position local x = test.x local y = test.y local z = test.z game.Workspace:FindFirstChild(game.Players.LocalPlayer.Name).HumanoidRootPart.CFrame = CFrame.new(Vector3.new(x,y+5,z)) print("ran") break
Error in trying to get the position of v