I’m having a problem with a remake of stalker im making with @Stickpuppet , and the problem is that it breaks when its choosing the stalker… Here are the functions that are broken:
function getAvailableStalker()
-- This function returns a random player who hasn't played as The Stalker on the server.
-- If everyone has, it resets the queue and returns a random player who is available.
local resetQualified = {}
local qualified = {}
for _,v in pairs(game.Players:GetPlayers()) do
-- Before we start checking if they qualify, we need to check if they get the Chance Booster
local chance = 1
if v:FindFirstChild("IntroPlayed") then
for i = 1,chance do
table.insert(resetQualified,v)
end
if v:WaitForChild("RecentStalker").Value ~= true then
for i = 1,chance do
table.insert(qualified,v)
end
end
end
end
if #qualified > 0 then
-- Select a random player from the available list
return qualified[math.random(1,#qualified)]
else
-- Reset everyone's RecentStalker value and select anyone who has played the intro
for _,v in pairs(resetQualified) do
v.RecentStalker.Value = false
end
return resetQualified[math.random(1,#resetQualified)]
end
end
function selectStalker()
-- This runs the selection messages.
script.SelectingStalker.Value = true
script.DisableInfoTyping.Value = true
local t = 0.03
script.InfoColor.Value = Color3.fromRGB(0,255,255)
local people = game.Players:GetPlayers()
for i = 1,20 do
wait(t)
h.Value = "Selecting The Stalker for the round: "..people[math.random(1,#people)].Name
c.Slash.Value = true
t = t + 0.03
print(t)
end
local selectedPlayer = getAvailableStalker()
h.Value = "Selecting The Stalker for the round: "..selectedPlayer.Name
wait(0.5)
return selectedPlayer
end
function countPlayers()
return (game.Players:FindFirstChild("Player1") ~= nil or game:GetService("RunService"):IsStudio()) and 5 or #game.Players:GetPlayers()
end
function makeStalker(player)
if player == nil then
makeStalker(getAvailableStalker())
end
script.DisableInfoTyping.Value = false
script.InfoColor.Value = Color3.fromRGB(255,0,0)
h.Value = "The Stalker this round is: "..player.Name
script.SelectingStalker.Value = false
local Clone=game.Lighting.GUIS.StalkerGui:Clone()
Clone.Parent=player.PlayerGui
player.Character.MakeStalker.Value = true
player.TeamColor = BrickColor.new("Bright red")
player.Character.Torso.CFrame = CFrame.new(game.Workspace["Map"..script.Map.Value].StalkerSpawn.Position)
player.Character.ClientsideEyes:Destroy()
player.Character.Humanoid.Died:Connect(function()
player.TeamColor = BrickColor.new("Institutional white")
end)
end