So my baseplate has the size: 100.65, 11.744, 100.65
Now I want a brick to spawn somewhere on the baseplate. But I think im mesing something up with the math.random() function. The following code is supposed to spawn the bricks at a random position on the baseplate as I already said. But they fly off the map.
while wait(0.4) do local Meteor = game.Lighting.Meteor:Clone() local PosX = math.random(0,100) local PosY = 130 local PosZ = math.random(0,100) Meteor.Parent = game.Workspace Meteor.Position = Vector3.new(PosX, PosY, PosZ) end
So I made it that pos x and z change since pos y needs to be the same hight.
1)
Lightning
is not used for storage. UseReplicatedStorage
orServerStorage
2) You will notice that when you clone your model, it will only clone once.
-- Declaration Section local meteor = game:GetService("ReplicatedStorage"):WaitForChild("Meteor") -- Processing Section while true do local xPosition = math.random(100) local yPosition = 130 local zPosition = math.random(100) print ("The meteor location is, " .. xPosition.. ", ".. yPosition .. ", ".. zPosition) local newMeteor = meteor:Clone() print ("Cloning meteor") newMeteor.Parent = workspace newMeteor.Position = Vector3.new(xPosition, yPosition, zPosition) print ("Added meteor") wait(0.5) print ("Redoing work") end