I’m trying to make a part randomly spawn in one of these 4 different positions. So when the game loads, it will load in one of the 4 positions. The next time it loads it will be in either the same position or one of the other 3 positions. Nothing happens when the game loads. Here is my code
local Positions = {
Vector3.new(-39.95, 0.5, -20.55),
Vector3.new(-52.35, 0.5, -21.15),
Vector3.new(-62.3, 0.5, -20.7),
Vector3.new(-71.7, 0.5, -20.85)
};
local Part = --Part
Part.Position = Positions[math.random(1, #Positions)]
What changed was that it actually put itself in these positions and not in the initial position + the position and remove the number names that you put it, since when you enter a [number] in a table, it returns the velor of that position.
This will work the same way as intended and to be honest, that’s just my thought but it looks cleaner since you’re just creating useless variables, really unnecessary in my opinion.
Anyway, I think you got confused and tried to add one Vector3 with another one, so yeah. If you were to do so just do it with a CFrame.
I tried putting
local Part = workspace:WaitForChild(“Part”)
and tried
local Part = workspace.Part
just to see if it would work but the part will just stay there and it still wont move load in one of the 4 positions. I tried it by having the part anchored and not anchored just to see if it would make a difference…
What I am trying to do is have a part randomly load in specific locations. Kind of the way keys and tools will randomly load in the Piggy game. Although they don’t just randomly load anywhere but specific places. I’m not sure if anyone may already have a working script? Or am I on the right track?
Hmm…when I try putting this code on an existing game I am developing it didn’t work but when I tried this on a new blank template, it worked!!! There may be some interfering with the rest of my code. I can work with this!!! I will have to dig to see where I went wrong. Thanks everyone!!!