I'm trying to make a script to where when a certain number is randomly generated it spawns a zombie. I hope someone could help me out!
game.Players.PlayerAdded:Connect(function() local ServStoarge = game:GetService('ServerStorage') local Zombie = ServStoarge.Zombie local Spawner = game.Workspace.Spawner while true do print(math.random(1, 5)) if math.random == 1 then Zombie:Clone() Zombie.HumanoidRootPart.CFrame = game.Workspace.Spawner.CFrame + Vector3.new(0, 2, 0) end end end)
The problem is the random number you generated with math.random(1,5)
is not stored anywhere, it is just printed.
You tried using if math.random == 1
but the random number you generated before was not stored.
Instead, you can check it in the if statement:
if math.random(1,5) == 1 then Zombie:Clone() Zombie.HumanoidRootPart.CFrame = game.Workspace.Spawner.CFrame + Vector3.new(0, 2, 0) end
If any errors appear or it doesn't work, let me know.