I'm making a hide and seek game and after it chooses the seeker the game restarts, Can anyone tell me why?
By the way its a while loop but I didn't show it to make it short
Here's the code
local seeker = selected[math.random(1,#selected)]
replicatedStorage:FindFirstChild("PlayerRoles"):FindFirstChild("Seeker").Value = seeker
table.remove(selected, getPositionOfPlayer(selected,seeker))
status.Value = seeker.Name.." has been selected as seeker!"
wait(2)
local SpawnPoints = cloneMap:FindFirstChild("SpawnPoints")
local AvailableSpawnPoints = SpawnPoints:GetChildren()
for i, player in pairs(selected) do
if player then
character = player.Character
if character ~= replicatedStorage:WaitForChild("PlayerRoles"):WaitForChild("Seeker").Value then
character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[1].CFrame
table.remove(AvailableSpawnPoints,1)
local GameTag = Instance.new("BoolValue")
GameTag.Name = "GameTag"
GameTag.Parent = player.Character
elseif character == replicatedStorage:WaitForChild("PlayerRoles"):WaitForChild("Seeker").Value then
character:FindFirstChild("HumanoidRootPart").CFrame = workspace:WaitForChild("SeekerWaitRoom"):WaitForChild("Spawn").CFrame
local seekerTag = Instance.new("BoolValue")
seekerTag.Name = "SeekerTag"
seekerTag.Parent = player.Character
else
if not player then
table.remove(selected, i)
end
end
end
end
end
