Asked by unknown no more
Can you check if i made any typos
local players = game: getservice(players)
local serverstorage = game:GetService(serverstorage)
local mapfolder = serverstorage:waitforchild(maps)
local amounttostart = 2 --required player account--
--functions--
function getplayers ()
local list = {}
for _, player in pairs (players:getplayers()) do
if player.character then
table.inset(list,player) --insert the player w/ character info
end
end
return list
end
function setupkiller(player : player)
local character = player.character
character:SetAttribute("survivor",true)
script: waitforchild('surivorValues'):Clone().Parent = character
end
--game loop--
while task.wait() do
local playerlist = getplayers() --should be a list of valid players
if #playerlist>= amounttostart then
local index = math.random(1,#playerlist) --will return a number between 1 and the # of players--
local chosenKiller = playerlist[index]
table.remove(playerlist,index) --remove killer from playerlist
setupkiller(chosenkiller)
for _, player in pairs (playerlist) do
setupsurvivor(player)
end
repeat task.wait()
until(1 ==2) --willl will prevent from looping over and over
end
end
local players = game: getservice(players)
local serverstorage = game:GetService(serverstorage)
local mapfolder = serverstorage:waitforchild(maps)
local amounttostart = 2 --required player account--
--functions--
function getplayers ()
local list = {}
for _, player in pairs (players:getplayers()) do
if player.character then
table.inset(list,player) --insert the player w/ character info
end
end
return list
end
function setupkiller(player : player)
local character = player.character
character:SetAttribute("survivor",true)
script: waitforchild('surivorValues'):Clone().Parent = character
end
--game loop--
while task.wait() do
local playerlist = getplayers() --should be a list of valid players
if #playerlist>= amounttostart then
local index = math.random(1,#playerlist) --will return a number between 1 and the # of players--
local chosenKiller = playerlist[index]
table.remove(playerlist,index) --remove killer from playerlist
setupkiller(chosenkiller)
for _, player in pairs (playerlist) do
setupsurvivor(player)
end
repeat task.wait()
until(1 ==2) --willl will prevent from looping over and over
end
end
Answers
There are no human answers yet.
Answered by
GPT-5 mini
Yes — there are a number of typos, capitalization mistakes and a few logic issues in the script. Below I list the problems I found and then give a corrected version of the script with small safety checks added.
Main typos / problems and fixes
- game: getservice(players)
- Should be game:GetService("Players") — GetService is capitalized and takes a string.
- game:GetService(serverstorage)
- Should be game:GetService("ServerStorage") — ServerStorage string and capitalization.
- serverstorage:waitforchild(maps)
- Should be ServerStorage:WaitForChild("Maps") — method name and argument are strings and capitalized.
- players:getplayers()
- Should be Players:GetPlayers() — camelCase and method name.
- player.character
- Should be player.Character (property names are capitalized).
- table.inset(...)
- Should be table.insert(...) (typo).
- function setupkiller(player : player)
- If using Luau type annotations use Player type: function setupKiller(player: Player). Also function name casing consistent.
- character:SetAttribute("survivor",true)
- Attribute name casing is your choice, but be consistent (e.g. "Survivor").
- script: waitforchild('surivorValues'):Clone().Parent = character
- Should be script:WaitForChild("SurvivorValues"):Clone().Parent = character — WaitForChild capitalization and "surivor" is misspelled as "survivor".
- chosenKiller vs chosenkiller
- Variable name mismatch (case).
- setupkiller(chosenkiller)
- Should call setupKiller(chosenKiller).
- setupsurvivor(player)
- Function not defined; if you intend setupSurvivor, define it and use consistent casing.
- repeat ... until(1 ==2)
- Condition (1 == 2) is always false; repeat-until loops until condition becomes true, so this causes an infinite loop. Use a real condition or break/sleep strategy.
Corrected version (with small safety checks)
- I normalize naming (Players, ServerStorage, camelCase functions), fix typos and add a setupSurvivor stub. Replace the infinite repeat-until with a wait-until the player count drops below the threshold (adjust to your desired logic).
Corrected script:
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local mapFolder = ServerStorage:WaitForChild("Maps")
local amountToStart = 2 -- required player count
-- functions --
local function getPlayers()
local list = {}
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
table.insert(list, player)
end
end
return list
end
local function setupKiller(player: Player)
local character = player.Character
if not character then return end
character:SetAttribute("Survivor", true)
local template = script:WaitForChild("SurvivorValues"):Clone()
template.Parent = character
end
local function setupSurvivor(player: Player)
local character = player.Character
if not character then return end
character:SetAttribute("Survivor", false)
-- If you have a different template for survivors, clone it here:
-- local template = script:WaitForChild("SurvivorValues"):Clone()
-- template.Parent = character
end
-- game loop --
while true do
task.wait(1)
local playerList = getPlayers()
if #playerList >= amountToStart then
local index = math.random(1, #playerList)
local chosenKiller = playerList[index]
table.remove(playerList, index) -- remove killer from playerList
setupKiller(chosenKiller)
for _, player in pairs(playerList) do
setupSurvivor(player)
end
-- Wait until players drop below the start amount before restarting (change logic as needed)
repeat
task.wait(1)
until #getPlayers() < amountToStart
end
end
Notes / suggestions
- Decide on a consistent attribute name and casing ("Survivor" vs "survivor") and use it consistently.
- If you use Luau type annotations, ensure your environment supports them. Player type is capitalized.
- The round restart condition above is a simple approach. You may prefer to wait for a round-end event, or a timer, instead of player count changes.
- Ensure "SurvivorValues" (or whatever asset name you use) exists under the script.
If you want, I can adapt the script to:
- Use events/timers for round start/end,
- Wait for characters to load properly (CharacterAdded handling),
- Or implement full round/respawn logic.
Main typos / problems and fixes
- game: getservice(players)
- Should be game:GetService("Players") — GetService is capitalized and takes a string.
- game:GetService(serverstorage)
- Should be game:GetService("ServerStorage") — ServerStorage string and capitalization.
- serverstorage:waitforchild(maps)
- Should be ServerStorage:WaitForChild("Maps") — method name and argument are strings and capitalized.
- players:getplayers()
- Should be Players:GetPlayers() — camelCase and method name.
- player.character
- Should be player.Character (property names are capitalized).
- table.inset(...)
- Should be table.insert(...) (typo).
- function setupkiller(player : player)
- If using Luau type annotations use Player type: function setupKiller(player: Player). Also function name casing consistent.
- character:SetAttribute("survivor",true)
- Attribute name casing is your choice, but be consistent (e.g. "Survivor").
- script: waitforchild('surivorValues'):Clone().Parent = character
- Should be script:WaitForChild("SurvivorValues"):Clone().Parent = character — WaitForChild capitalization and "surivor" is misspelled as "survivor".
- chosenKiller vs chosenkiller
- Variable name mismatch (case).
- setupkiller(chosenkiller)
- Should call setupKiller(chosenKiller).
- setupsurvivor(player)
- Function not defined; if you intend setupSurvivor, define it and use consistent casing.
- repeat ... until(1 ==2)
- Condition (1 == 2) is always false; repeat-until loops until condition becomes true, so this causes an infinite loop. Use a real condition or break/sleep strategy.
Corrected version (with small safety checks)
- I normalize naming (Players, ServerStorage, camelCase functions), fix typos and add a setupSurvivor stub. Replace the infinite repeat-until with a wait-until the player count drops below the threshold (adjust to your desired logic).
Corrected script:
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
local mapFolder = ServerStorage:WaitForChild("Maps")
local amountToStart = 2 -- required player count
-- functions --
local function getPlayers()
local list = {}
for _, player in pairs(Players:GetPlayers()) do
if player.Character then
table.insert(list, player)
end
end
return list
end
local function setupKiller(player: Player)
local character = player.Character
if not character then return end
character:SetAttribute("Survivor", true)
local template = script:WaitForChild("SurvivorValues"):Clone()
template.Parent = character
end
local function setupSurvivor(player: Player)
local character = player.Character
if not character then return end
character:SetAttribute("Survivor", false)
-- If you have a different template for survivors, clone it here:
-- local template = script:WaitForChild("SurvivorValues"):Clone()
-- template.Parent = character
end
-- game loop --
while true do
task.wait(1)
local playerList = getPlayers()
if #playerList >= amountToStart then
local index = math.random(1, #playerList)
local chosenKiller = playerList[index]
table.remove(playerList, index) -- remove killer from playerList
setupKiller(chosenKiller)
for _, player in pairs(playerList) do
setupSurvivor(player)
end
-- Wait until players drop below the start amount before restarting (change logic as needed)
repeat
task.wait(1)
until #getPlayers() < amountToStart
end
end
Notes / suggestions
- Decide on a consistent attribute name and casing ("Survivor" vs "survivor") and use it consistently.
- If you use Luau type annotations, ensure your environment supports them. Player type is capitalized.
- The round restart condition above is a simple approach. You may prefer to wait for a round-end event, or a timer, instead of player count changes.
- Ensure "SurvivorValues" (or whatever asset name you use) exists under the script.
If you want, I can adapt the script to:
- Use events/timers for round start/end,
- Wait for characters to load properly (CharacterAdded handling),
- Or implement full round/respawn logic.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.