I am currently working on an ATM robbery type system, and I need to money to actually eject out instead of stack in one part, but in not exactly sure how to do it
-code
local ejected = false
local bill = game.ReplicatedStorage.Bill
local function eject()
local Bill = bill:Clone()
Bill.Parent = workspace
Bill.Position = script.Parent.EjectPos.Position
local Bill2 = bill:Clone()
Bill2.Parent = workspace
Bill2.Position = script.Parent.EjectPos.Position
local Bill3 = bill:Clone()
Bill3.Parent = workspace
Bill3.Position = script.Parent.EjectPos.Position
local Bill4 = bill:Clone()
Bill4.Parent = workspace
Bill4.Position = script.Parent.EjectPos.Position
local Bill5 = bill:Clone()
Bill5.Parent = workspace
Bill5.Position = script.Parent.EjectPos.Position
end
while true do
if script.Parent.Humanoid.Health <= 0 then
if ejected == true then
print("wait for the cool don")
else
print("eject")
eject()
ejected = true
end
end
wait()
end
Instead of doing it 5 times, you can use a for loop. Something like:
for i = 1, 5 do
local Bill = bill:Clone()
Bill.Parent = workspace
Bill.Position = script.Parent.EjectPos.Position
end