I want to have a weapon spawner only start the spawner timer after the player equips the tool. my reasoning is because the weapons will continue to spawn on each other. I tried to check if the tool clones parent was not in the workspace but it didn’t work.
part = script.Parent
Rs = game:GetService("ReplicatedStorage")
Weapons = Rs.Common
function SpawnRandomWeapon()
local WeaponsTable = Weapons:GetChildren()
local RandomWeapon = WeaponsTable[math.random(1, #WeaponsTable)]
local WeaponClone = RandomWeapon:Clone()
WeaponClone.Parent = workspace["Common Spawner"]
WeaponClone.Handle.CFrame = part.CFrame
if WeaponClone.Parent ~= workspace then
print("not in workspace")
end
end
SpawnRandomWeapon()
while wait(math.random(1, 6)) do
SpawnRandomWeapon()
end
part = script.Parent
Rs = game:GetService("ReplicatedStorage")
Weapons = Rs.Common
function SpawnRandomWeapon()
local WeaponsTable = Weapons:GetChildren()
local RandomWeapon = WeaponsTable[math.random(1, #WeaponsTable)]
local WeaponClone = RandomWeapon:Clone()
WeaponClone.Handle.CFrame = part.CFrame
WeaponClone.Parent = workspace["Common Spawner"]
repeat task.wait() until WeaponClone.Parent ~= workspace["Common Spawner"]
print("not in workspace")
end
SpawnRandomWeapon()
while task.wait(math.random(1, 6)) do
SpawnRandomWeapon()
end
I’m assuming that you only want a weapon to spawn when a weapon isn’t already under the spawner. Try it out and let me know if this is what you want.