What do you want to achieve? I am trying to make a bomb spawn in random locations.
What is the issue? While the first bomb will spawn, the second one won’t.
What solutions have you tried so far? I have tried tweaking the script a bit but none of my solutions seem to work. Any help?
while game.Workspace.Difficulty.Value > 0 do
local time = game.Workspace.Difficulty.Value
wait(time)
game.ReplicatedStorage.Bomb:Clone()
game.ReplicatedStorage.Bomb.Parent = workspace
repeat wait() until game.Workspace.Bomb
game.Workspace.Bomb.Position = math.random(-3.3, 91.8), 34.15, math.random(-91.8, 4.6)
time = time - 0.1
end
Since you’re cloning the bomb out of ReplicatedStorage directly, it will only clone once. To get around this, create a local variable for your clone, parent it and position it. I don’t believe it’s necessary to use a repeat wait loop here. If you want to check the existence of your cloned bomb, use FindFirstChild or check that your bomb is not equal to nil.
while game.Workspace.Difficulty.Value > 0 do
local time = game.Workspace.Difficulty.Value
wait(time)
local bomb = game.ReplicatedStorage.Bomb:Clone()
bomb.Parent = workspace
if bomb ~= nil then
Bomb.Position = Vector3.new(math.random(-3.3, 91.8), 34.15, math.random(-91.8, 4.6)) -- Should be vector3
time = time - 0.1
end
end
while game.Workspace.Difficulty.Value > 0 do
local time = game.Workspace.Difficulty.Value
wait(time)
local bomb2 = game.ReplicatedStorage.Bomb:Clone() -- i found two errors in the code btw, the first one was here.
if bomb2 then
bomb2.Parent = game.Workspace
repeat wait() until game.Workspace.Bomb
game.Workspace.Bomb.Position = Vector3.new(math.random(-3.3, 91.8), 34.15, math.random(-91.8, 4.6)) -- the second error was here
time -= .1
end
end