Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Part not moving to the correct spot?

Asked by 8 years ago

This is supposed to spawn parts randomly in, well, random positions, but in a limited space, but it only spawns in one place.


local max = 2100 local Met = script.Projectile:Clone() local Boom = script.Impact:Clone() script.Projectile:Destroy() script.Impact:Destroy() function DropMeteor() print("Dropped") local newMet = Met:Clone() newMet.Parent = game.Workspace newMet.CFrame= CFrame.new(Vector3.new(math.random(max), math.random(500,666),math.random(max))) newMet.Anchored = false wait(math.random(5,33)) DropMeteor() end DropMeteor() for i = 1,math.random(25) do DropMeteor() end
0
FTFY User#6546 35 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
while wait(1) do --Make sure to put in a wait number.
local Part = Instance.new("Part", game.Workspace)
Part.Name = 'FallingBlock'
Part.Position = Vector3.new(math.random(1,100), math.random(1,100),  math.random(1,100)) -- (1,100), 1 = Min, 100 = Max. First math.random is X, second is Y, Third is Z.
end

To make it more simple:

while wait(1) do --Make sure to put in a wait number.
XPos = math.random(1,100)
YPos = math.random(1,100)
ZPos = math.random(1,100)
local Part = Instance.new("Part", game.Workspace)
Part.Name = 'FallingBlock'
Part.Position = Vector3.new(XPos, YPos, ZPos)
end
Ad

Answer this question