Servers Script works in studio but not InGame

wait(1)
local WeaponsFolder = game.ReplicatedStorage:WaitForChild("Weapons"):GetChildren()
local IngamePlayers = game:GetService("Players"):GetChildren()


--Original Script created by TTC Meliodas(Youtube)--
while true do --This makes sure it keeps going and doesn't die out on us
wait(5) --This is how long until the games are started. Recomended that you keep to 5
local m = math.random(1,1) --This randomly selects a game. The seven shows how many games there are
local player = game.Players:GetPlayers()
for i = 1, #player do --This checks for players and gets them
msg = Instance.new("Message") --This make the annoying messages that appear on you screen
msg.Parent = nil --This identifies the game
if m == 1 then --don't change unless you know what you are doing
msg.Parent = game.Workspace --This makes sure it says and appears in the workspace
msg.Text = "Choosing Minigame." --A bunch of messages to tell you that the game is starting which you can change if desired
wait(1)
msg.Text = "Choosing Minigame.."
wait(1)
msg.Text = "Choosing Minigame..."
wait(1)
msg.Text = "A Minigame has been chosen!"
wait(3)
msg.Text = "The Minigame is..."
wait(3)
msg.Text = "City" --Put the name of the minigame you want it to be called
wait(2)
msg.Text = "Be The Last One Standing" --Put the rules of the minigame
wait(5)
msg.Text = "The game will be starting in:"
wait(1)
msg.Text = "...3..."
wait(1)
msg.Text = "..2.."
wait(1)
msg.Text = ".1."
wait(1)
msg.Text = "Begin!"
wait(1)			
msg:remove() --This removes the annoying messages Don't mess with!

local RandomWeapon = WeaponsFolder[math.random(1,#WeaponsFolder)]:Clone()
for i,v in pairs (IngamePlayers) do
	wait(1)
	print(v)
	RandomWeapon.Parent = v.Backpack	
end
			game.ReplicatedStorage.Minigame1:clone().Parent = game.Workspace
			for i,v in pairs(IngamePlayers) do
			wait(1)
			for i,spwn in pairs(game.ReplicatedStorage.Minigame1.Spawns:GetChildren()) do
				wait(1)
				print("works")
				if spwn.Free.Value == true then
						print(spwn.CFrame)
						player[i].Character:MoveTo(spwn.CFrame.Position)
						spwn.Free.Value = false
						print("spawn works ")

						local spwnTag = Instance.new("StringValue")
						spwnTag.Name = "SpawnTag"
						spwnTag.Value = spwn.Name
						spwnTag.Parent = player[i]
						break
					end	
				end
			end
			-- Make a minigame then name it just like this: Minigame1 Once it is named that, put it in the position on the map were you want it to go then put the model in lighting. After you put the model in lighting, you may delete the one in workspace if you wish.
			wait(10)
			for _,v in pairs(IngamePlayers) do 
				wait(1)
				v.Backpack[RandomWeapon]:Destroy()--How long the game lasts
				local spawnTag = v.SpawnTag.Value
				local spwn = game.ReplicatedStorage.Minigame1.Spawns[spawnTag]
				spwn.Free.Value = true
			end
msg.Parent = game.Workspace
msg.Text = "Winner!" --After the game ends, this shows a message/messages at the end. Edit if you want.
wait(3)
msg:remove() 
game.Workspace.Minigame1:Remove() --Removes the brick so all players die (except spectators) and removes the brick so a new game can start (recommended games aren't over 5 minutes so spectators aren't bored)
end

okay this is a server script in serverscriptservice it works perfectly in studio but it doesnt work ingame it just spawns the map
solutions i’ve tried is publishing game,enabling api requests i rly dont know what the problem is
What this script is supposed to do is countdown then tp u to a map with random spawnpoints for every player and give the same random weapon to every player

1 Like

Im pretty sure it is game:GetPlayers. (just gotta point that out).

thanks dude but that didnt fix it

Also, I think # are only for tables.

Try looking through console in the game.

getchildren returns a table doesnt it?

GetChildren returns all of the children of the Value.

Is this a model? or did you make it?

in an array which is a table also console doesnt show anytihng

only the msg nd random map spawn part is a model i put in the rest

im pretty sure you get Players with

for index, value in pairs(players) do

end

I meant like did you use a free model?

yes im doing this for a client he wanted me to add give same random weapon to everyone nd random map spawn nd i am using a for loop for getting players

any beta features? can you post the link of the game for better insight?

but it doesnt work ingame
no beta features

Found a problem, on line 49, and 51 change one of the I statements.

the for i ,v statements? cuz i tried deleting them nd using only 1 for loop on top for everything

ha, Ive found it! (I think) when you use a for I = 1 then it willingly run one client at a time.

nvm i understand what u meant lemme try

wait(1)
local WeaponsFolder = game.ReplicatedStorage:WaitForChild("Weapons"):GetChildren()
local IngamePlayers = game:GetService("Players"):GetPlayers()


--Original Script created by TTC Meliodas(Youtube)--
while true do --This makes sure it keeps going and doesn't die out on us
wait(5) --This is how long until the games are started. Recomended that you keep to 5
local m = math.random(1,1) --This randomly selects a game. The seven shows how many games there are
	local player = game.Players:GetPlayers()
for i,v in pairs(IngamePlayers) do
msg = Instance.new("Message") --This make the annoying messages that appear on you screen
msg.Parent = nil --This identifies the game
if m == 1 then --don't change unless you know what you are doing
msg.Parent = game.Workspace --This makes sure it says and appears in the workspace
msg.Text = "Choosing Minigame." --A bunch of messages to tell you that the game is starting which you can change if desired
wait(1)
msg.Text = "Choosing Minigame.."
wait(1)
msg.Text = "Choosing Minigame..."
wait(1)
msg.Text = "A Minigame has been chosen!"
wait(3)
msg.Text = "The Minigame is..."
wait(3)
msg.Text = "City" --Put the name of the minigame you want it to be called
wait(2)
msg.Text = "Be The Last One Standing" --Put the rules of the minigame
wait(5)
msg.Text = "The game will be starting in:"
wait(1)
msg.Text = "...3..."
wait(1)
msg.Text = "..2.."
wait(1)
msg.Text = ".1."
wait(1)
msg.Text = "Begin!"
wait(1)			
msg:remove() --This removes the annoying messages Don't mess with!

local RandomWeapon = WeaponsFolder[math.random(1,#WeaponsFolder)]:Clone()
	print(v)
	RandomWeapon.Parent = v.Backpack	
			game.ReplicatedStorage.Minigame1:clone().Parent = game.Workspace
			wait(1)
			for _,spwn in pairs(game.ReplicatedStorage.Minigame1.Spawns:GetChildren()) do
				wait(1)
				print("works")
				if spwn.Free.Value == true then
						print(spwn.CFrame)
						v.Character:MoveTo(spwn.CFrame.Position)
						spwn.Free.Value = false
						print("spawn works ")

						local spwnTag = Instance.new("StringValue")
						spwnTag.Name = "SpawnTag"
						spwnTag.Value = spwn.Name
						spwnTag.Parent = v
						break
					end	
				end
			-- Make a minigame then name it just like this: Minigame1 Once it is named that, put it in the position on the map were you want it to go then put the model in lighting. After you put the model in lighting, you may delete the one in workspace if you wish.
			wait(10)
			v.Backpack[RandomWeapon]:Destroy()--How long the game lasts
			local spawnTag = v.SpawnTag.Value
			local spwn = game.ReplicatedStorage.Minigame1.Spawns[spawnTag]
				spwn.Free.Value = true
msg.Parent = game.Workspace
msg.Text = "Winner!" --After the game ends, this shows a message/messages at the end. Edit if you want.
wait(3)
msg:remove() 
game.Workspace.Minigame1:Remove() --Removes the brick so all players die (except spectators) and removes the brick so a new game can start (recommended games aren't over 5 minutes so spectators aren't bored)
end

okay so this is what i’ve changed so far in the script still works in studio but now it doesnt even show msgs in real game