[ok i found solution]
script.Parent.Transparency = 1 while wait(math.random(29, 90)) do -- random time to spawn z = game.ReplicatedStorage.zombie:Clone() local hp = z.Humanoid.MaxHealth z:MoveTo(script.Parent.Position) -- move to the spawner's location z.Parent = workspace z.Humanoid.MaxHealth = math.random(25,100) -- random health z.Humanoid.Health = z.Humanoid.MaxHealth if hp < 50 then --change skin collor due to health z["Left Arm"].Color = Color3.fromRGB(39, 70, 45) z["Right Arm"].Color = Color3.fromRGB(39, 70, 45) z["Head"].Color = Color3.fromRGB(39, 70, 45) else z["Left Arm"].Color = Color3.fromRGB(52, 142, 64) z["Right Arm"].Color = Color3.fromRGB(52, 142, 64) z["Head"].Color = Color3.fromRGB(52, 142, 64) end end
it just ignores line 6 for some reason [ok i found solution]
2 Things I changed:
Put Waiting at the End and not inside while ... do so it always has a random time
SetPrimaryPartCFrame instead of MoveTo
script.Parent.Transparency = 1 while true do -- random time to spawn z = game.ReplicatedStorage.zombie:Clone() local hp = z.Humanoid.MaxHealth z:SetPrimaryPartCFrame(script.Parent.Position) -- move to the spawner's location z.Parent = workspace z.Humanoid.MaxHealth = math.random(25,100) -- random health z.Humanoid.Health = z.Humanoid.MaxHealth if hp < 50 then --change skin collor due to health z["Left Arm"].Color = Color3.fromRGB(39, 70, 45) z["Right Arm"].Color = Color3.fromRGB(39, 70, 45) z["Head"].Color = Color3.fromRGB(39, 70, 45) else z["Left Arm"].Color = Color3.fromRGB(52, 142, 64) z["Right Arm"].Color = Color3.fromRGB(52, 142, 64) z["Head"].Color = Color3.fromRGB(52, 142, 64) end wait(math.random(29, 90)) end