Okay, so here is my problem: there may be some dumb errors in it, but that's because I've been editing it so much to desperately fix it...
I'm making a game that relies on waves of enemies being spawned, I have this so far as a script:
Wave = 1
print("Wave Loaded")
function Create(item,amount,Xran1,Xran2,Zran1,Zran2,CPart)
for i = 1, amount do
if item then
local Creation = game.ServerStorage.Instances.item
local Instance = Creation:Clone()
Instance.Parent = game.Workspace
local xpos = math.random(Xran1,Xran2) --To spawn grunts in an area
local zpos = math.random(Zran1,Zran2)
Instance[CPart].CFrame = CFrame.new(xpos,50,zpos)
wait(0.01)
else
print("Item is nil") -- always prints this, never actually spawns grunt
end
end
end
wait(0.5)
print("Running function...")
Create(Grunt, 20, -78.44,-81.5, -27.71, -30.5, Torso) --Seems to not take grunt as an argument
print("Function ran")
whenever I run the create function, it seems to not take Grunt as an argument to spawn, I have no idea what to do and I've tried numerous things including have it do FindFirstChild instead, having it do waitForChild. An exception is replacing "Item" with "Grunt" in the actual function,which makes it work, so my guess is I'm doing something wrong with giving it the argument "Item", It does the same with the argument "CPart", where if I replace it with torso in the actual function, it works fine
If something like this was posted before, I have not been able to find it Any help would be greatly appreciated

2 comments
Thank you so much! It's strange that it works now, though, because I tried that, and tried switching the Xran and Zran values and it didn't work...either way, I'm happy it's finally working, thanks!
No problem man! :)