In the video as you can see i dont even move my character or pressed any keys, it just starts to lagging and the camera and character’s physics bugging, and also the script just spawn the character to the example rigs, i tried rename the template rigs to the different names but it seems to not working
This just happens few days ago, before that it just works completly fine.
local zombieteam = game.Teams.Zombies
local players = game:GetService("Players")
local mutations = game.ServerStorage:FindFirstChild("Mutations"):GetChildren()
players.CharacterAutoLoads = false
local spawntime = 5
local function randomize()
local randomIndex = math.random(1, #mutations)
local mut = mutations[randomIndex]
return mut:Clone()
end
local function copyAccessories(player, newZombie)
local character = player.Character or player:LoadCharacter()
if character then
for _, accessory in pairs(character:GetChildren()) do
if accessory:IsA("Accessory") then
local clonedAccessory = accessory:Clone()
clonedAccessory.Parent = newZombie
end
end
end
end
local function spawnZombieWithAccessories(player)
local newZombie = randomize()
newZombie.Name = player.Name
for _, script in pairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
local clonedScript = script:Clone()
clonedScript.Parent = newZombie
end
copyAccessories(player, newZombie)
newZombie.Humanoid.RequiresNeck = true
player.Character = newZombie
newZombie.HumanoidRootPart.CFrame = workspace["z team spawn"].CFrame + Vector3.new(0,1,0)
newZombie.Parent = workspace
end
local function spawning(player)
if player.Team == zombieteam then
spawnZombieWithAccessories(player)
else
player:LoadCharacter()
local normalanimate = script.Animate:Clone()
if player.Character:FindFirstChild("Animate") then return end
normalanimate.Parent = player.Character
end
end
local function adding(player)
player.CharacterAdded:Connect(function(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
wait(spawntime)
spawning(player)
end)
end)
spawning(player)
end
players.PlayerAdded:Connect(adding)
for _, player in pairs(players:GetPlayers()) do
player:GetPropertyChangedSignal("Team"):Connect(function()
spawning(player)
end)
end
players.PlayerAdded:Connect(function(player)
player:GetPropertyChangedSignal("Team"):Connect(function()
spawning(player)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
if player.Team == zombieteam then
local zombie = workspace:FindFirstChild(player.Name)
if zombie then
zombie:Destroy()
end
end
end)