SOLVED (Kinda): It was because the code was having issue figuring out which type of entities. In the folder described below, everything in ‘ZombiesInGame’ was called ‘Zombie’ so I guess the code couldn’t ‘Get Children’ correctly because it thought there was 1 maybe?
So I can’t add ALL the code, otherwise my game will be easily replicated. And even though its basic, idk I just don’t wanna release- anywho!
The issue is simple, I just lack the ability to solve it.
BASICALLY. I want my script to pick a random ‘Zombie’ from my replicated storage folder and spawn it.
My system atm works perfectly but when I tried to code it to pick multiple; that’s where I faltered.
I just want the script to choose a ‘zombie’ from the folder at random and spawn it in. Just so the map has variety than just 1 simple green and brown zamble xD
code:
local spawn = script.Parent.Locations (Parts used as Spawnplates, just regular parts)
for _, spwn in pairs(spawn:GetChildren()) do
if spwn:IsA('BasePart') then
local Max = ZombieTypes:GetChildren()
if #Max == 0 then continue end
local zombieCopy = ZombieTypes[math.random(1, #Max)]:Clone() -- It's here, script logs give me random numbers (7,22,14 etc... I only have 5 Zombies to choose from).
zombieCopy.Parent = zombiesInGame -- This is an empty folder that the replicated storage Clones them too. I can't add this part of the code but it's not part of the issue.
zombieCopy.HumanoidRootPart.CFrame = CFrame.new(spwn.Position + Vector3.new(0,1,0))
zombieCopy.Humanoid.Health = health
zombieCopy.Configuration.AttackDamage.Value = damageTotal
end
end
-------
Any solutions or Ideas is appreciated. I’m novice at coding so I apologize if my code is crop. If you need any more information I will provide.