local button = script.Parent.Spawn1
local button2 = script.Parent.Spawn2
local button3 = script.Parent.Spawn5
local rs = game:GetService('ReplicatedStorage')
local zombie = rs.Objects:FindFirstChild('Drooling Zombie')
button.MouseButton1Click:Connect(function(plr)
local positionX = math.random(-125, 125)
local positionZ = math.random(-125, 125)
local zombieClone = zombie:Clone()
zombieClone.Parent = workspace:FindFirstChild('Zombies')
zombieClone:FindFirstChild('HumanoidRootPart').CFrame = CFrame.new(positionX, 15, positionZ)
end)
button2.MouseButton1Click:Connect(function(plr)
for i = 1,2 do
local positionX = math.random(-125, 125)
local positionZ = math.random(-125, 125)
local zombieClone = zombie:Clone()
zombieClone.Parent = workspace:FindFirstChild('Zombies')
zombieClone:FindFirstChild('HumanoidRootPart').CFrame = CFrame.new(positionX, 15, positionZ)
end
end)
button5.MouseButton1Click:Connect(function(plr)
for i = 1,5 do
local positionX = math.random(-125, 125)
local positionZ = math.random(-125, 125)
local zombieClone = zombie:Clone()
zombieClone.Parent = workspace:FindFirstChild('Zombies')
zombieClone:FindFirstChild('HumanoidRootPart').CFrame = CFrame.new(positionX, 15, positionZ)
end
end)
It just seems repetitive and I was just wondering if this code could be made more compact and smaller

1 comment
wow you went out of your way to make my code even better props to you tysm