So, i have a value in the replicated storage, with a server script. The server script detects whenever the value is changed to true, or false. Here is my code:
local myZombie = game.ReplicatedStorage.Zombie:Clone()
local part = script.Parent
local model = script.Parent.Parent
local myHumanoidRootPart = myZombie.HumanoidRootPart
local myHumanoid = myZombie:WaitForChild("Zombie")
local inGame = game.ReplicatedStorage.GameInProgress
if inGame.Value == true then
myZombie:SetPrimaryPartCFrame(part.CFrame * CFrame.new(0, 5, 0))
myZombie.Parent = model
myHumanoid.Died:Connect(function()
wait(7)
local newZombie = game.ReplicatedStorage.Zombie:Clone()
newZombie.Parent = model
newZombie:SetPrimaryPartCFrame(part.CFrame * CFrame.new(0, 5, 0))
if myZombie then
myZombie:Destroy()
end
end)
end
inGame.Changed:Connect(function(value)
if value == true then
myZombie:SetPrimaryPartCFrame(part.CFrame * CFrame.new(0, 5, 0))
myZombie.Parent = model
myHumanoid.Died:Connect(function()
wait(7)
local newZombie = game.ReplicatedStorage.Zombie:Clone()
newZombie.Parent = model
end)
else
local zombie = model:FindFirstChild("Zombie")
if zombie then
zombie:Destroy()
end
end
end)
It clones whenever the value is set to true, and makes sure there is not more than one zombie in the model, and once the value is set to false, the script automatically destroys the zombie (if it is there) so that people can be in the map until a new round starts.
The error here is whenever i set the value to true, the zombies never spawn in.
I have a feeling that i am doing something wrong here that is very simple, but i don't know what. Help would be very appreciated.

1 comment
that wasnt it