So I have been trying to fix this code, I’m trying to make a group clone spawn in a random position.
I am trying to identify the clones origin position on lua but it has a space in it I have tried origin_position, Origin Position, OriginPosition. But they all just come out as errors, can somebody help me?
I have been working on this for the last hour, I have even tried pulling the object out and adding a respawning script but I can’t figure out how to make that either.
local parts = game.ReplicatedStorage.Parts:GetChildren()
while wait() do
local randompart = (parts[math.random(1, #parts)])
local clone = randompart:Clone()
clone.Parent = game.Workspace
clone.Position = Vector3.new(math.random(-26.648, 22.198), 0.001, math.random(-65.912, -17.242)) -- I am having problems with this.
wait(120)
clone:Destroy()
wait(120)
end
local rs = game:GetService("ReplicatedStorage")
local partFolder = rs:WaitForChild("Parts")
local parts = partFolder:GetChildren()
local debris = game:GetService("Debris")
while task.wait() do
local randompart = (parts[math.random(1, #parts)])
local clone = randompart:Clone()
clone.Parent = workspace
clone:MoveTo(Vector3.new(math.random(-25, 25), 0, math.random(-65, -20))) --math.random should use whole integers
debris:AddItem(clone, 120)
task.wait(120)
end