Hello I would like to know how can i make a random respawn in the “basepale” for the zombie model
Script:
local NPC = game.ReplicatedStorage.Zombie
local spawner = script.Parent
while true do
local Clone = NPC: Clone(5)
Clone.Parent = workspace
Clone.Torso.CFrame = spawner.CFrame
wait(3)
end
Use SetPrimaryPartCFrame instead of setting torso’s CFrame.
Try this.
local NPC = game.ReplicatedStorage.Zombie
local spawner = script.Parent
while true do
local Clone = NPC:Clone(5)
Clone.Parent = workspace
Clone:SetPrimaryPartCFrame(spawner.CFrame)
wait(3)
end
You mean you want it to spawn in a random location right??
local NPC = game.ReplicatedStorage.Zombie
local spawner = script.Parent
local centerposition = Vector3.new(0,5,0) --center of your map
local xSize = 30 --how big map is on X axis
local zSize = 30 -- how big your map is on Y axis
while true do
local Clone = NPC: Clone(5)
Clone.Parent = workspace
local randomX, randomZ = math.random(-xSize/2,xSize/2), math.random(-zSize/2,zSize/2)
Clone.Torso.CFrame = CFrame.new(centerposition + Vector3.new(randomX, 0, randomZ
wait(3)
end
it happens exactly the same as with my code I press play and they always appear next to me, I need to make 1 zombie appear every 1 second and make it random in the basepale
code
local NPC = game.ReplicatedStorage.Zombie
local spawner = script.Parent
local centerposition = Vector3.new(0,5,0) --center of your map
local xSize = 30 --how big map is on X axis
local zSize = 30 -- how big your map is on Y axis
while true do
local Clone = NPC: Clone(5)
Clone.Parent = workspace
local randomX, randomZ = math.random(-xSize/2,xSize/2), math.random(-zSize/2,zSize/2)
Clone.Torso.CFrame = CFrame.new(centerposition + Vector3.new(randomX, 0, randomZ))
wait(3)
end
the problem is that only 2 spawn and they don’t appear anymore … I need to make 1 appear every 1 second
Then, try this.
local NPC = game.ReplicatedStorage.Zombie
local spawner = script.Parent
while true do
wait(1)
local Clone = NPC:Clone()
Clone.Parent = workspace
Clone:SetPrimaryPartCFrame(spawner.CFrame)
end
Try creating a script in ServerScriptService, and type this.
local NPC = game.ReplicatedStorage.Zombie
local spawner = game.Workspace:FindFirstChild(“Spawner”)
while true do
wait(1)
local Clone = NPC:Clone()
Clone.Parent = workspace
Clone:SetPrimaryPartCFrame(spawner.CFrame)
end
I think you inserted wrong script or messed it up. There is nothing related to torso in script.
local NPC = game.ReplicatedStorage.Zombie
local spawner = game.Workspace:FindFirstChild(“Spawner”)
while true do
wait(1)
local Clone = NPC:Clone()
Clone.Parent = workspace
Clone:SetPrimaryPartCFrame(spawner.CFrame)
end
Copy and paste it to server script.
And click to the error in output and see where it takes you to.
It was an error of the scripts that the zombie had, I just eliminated the zombie scripts and the output does not give me any error but only 2 zombies continue to appear