im making a asymetrical horror game like forsaken and im trying to make it so that when the round starts the players are switched to their characters, this is my code so far but it doesn’t work
im posting the full script just in case
server script:
local playerCount = #game.Players:GetPlayers()
local plrs = game.Players:GetPlayers()
wait(1)
spawn(function()
while true do
wait(0)
playerCount = #game.Players:GetPlayers()
end
end)
while true do
wait(1)
if playerCount <= 0 then
script.Parent.Time.Value = 60
else
script.Parent.Time.Value = script.Parent.Time.Value - 1
print("a")
if script.Parent.Time.Value == 0 then
if workspace.inRound.Value == false then
workspace.inRound.Value = true
script.Parent.Time.Value = 240
local players = game:GetService("Players"):GetPlayers()
local killer = players[math.random(1, #players)]
killer.Character.killer.Value = true
local oldpos = killer.Character.HumanoidRootPart.CFrame --where character change starts
local killercharacter = game.ReplicatedStorage["Butcher Files"].StarterCharacter:Clone()
killercharacter.Name = killer.Name
killercharacter.Parent = workspace
killercharacter.HumanoidRootPart.CFrame = oldpos
if killer.Character then
killer.Character:Destroy()
end
killer.Character = killercharacter
game.ReplicatedStorage.ChangeCamSubject:FireClient(killer, killercharacter) -- where it ends
local folder = workspace:FindFirstChild("Killer Spawns"):GetChildren()
print(folder)
if #folder > 0 then
local Killerspawn = folder[Random.new():NextInteger(1, #folder)]
killer.Character:WaitForChild("HumanoidRootPart").CFrame = Killerspawn.CFrame * CFrame.new(0, 4, 0)
print(Killerspawn)
else
print("No spawns!")
end
print(killer)
for _, player in pairs(players) do
if player.Name == killer.Name then continue end
if player.Character and player.Character:FindFirstChild("survivor") then
player.Character.survivor.Value = true
end
print(player)
local spawns = workspace:FindFirstChild("Survivor spawns"):GetChildren()
if #spawns > 0 then
local survivorspawn = spawns[Random.new():NextInteger(1, #spawns)]
player.Character:WaitForChild("HumanoidRootPart").CFrame = survivorspawn.CFrame * CFrame.new(0, 4, 0)
print(survivorspawn)
else
print("No spawns!")
end
end
else
workspace.inRound.Value = false
script.Parent.Time.Value = 50
end
end
end
end
local script in starter character scripts:
game.ReplicatedStorage.ChangeCamSubject.OnClientEvent:Connect(function(killer, killercharacter)
game.Workspace.CurrentCamera.CameraSubject = killer.Humanoid
end)
