I made a tool that spawns every 5 seconds and despawns in another 5 seconds, it works fine but the issue is, whenever you would pick up the item, 5 seconds later it would delete in the players backpack and spawn back at the spawn
local ReplicatedStorage = game.ReplicatedStorage
local Gun = ReplicatedStorage:WaitForChild('MK-18')
local GunSpawn = workspace.Spawners:WaitForChild('Spawn')
while wait(5) do
local NewGun = GunSpawn:Clone()
NewGun.Parent = GunSpawn
game:GetService'Debris':AddItem(NewGun ,5)
end
I tried everything for fixing it, Any advice would be good thanks!
local ReplicatedStorage = game.ReplicatedStorage
local Gun = ReplicatedStorage:WaitForChild('MK-18')
local GunSpawn = workspace.Spawners:WaitForChild('Spawn')
while wait(5) do
local NewGun = GunSpawn:Clone()
NewGun.Parent = GunSpawn
if NewGun.Parent == GunSpawn then
game:GetService'Debris':AddItem(NewGun ,5)
end
end
local ReplicatedStorage = game.ReplicatedStorage
local Gun = ReplicatedStorage:WaitForChild('MK-18')
local GunSpawn = workspace.Spawners:WaitForChild('Spawn')
local GunSpawnClone = GunSpawn:Clone()
GunSpawnClone.Parent = workspace
while true do
task.wait(5)
local NewGun = Gun:Clone()
NewGun.Parent = GunSpawnClone
if NewGun.Parent == GunSpawnClone then
game:GetService'Debris':AddItem(NewGun ,5)
end
end
yup, because its waiting 5 seconds while the player has the tool. you could do this :
local ReplicatedStorage = game.ReplicatedStorage
local Gun = ReplicatedStorage:WaitForChild('MK-18')
local GunSpawn = workspace.Spawners:WaitForChild('Spawn')
while true do
task.wait(5)
local NewGun = Gun:Clone()
NewGun.Parent = GunSpawn
task.wait(5)
if NewGun.Parent == GunSpawn then
game:GetService'Debris':AddItem(NewGun ,0)
end
end