So i'm making a game where you kidnap people. I scripted the tools and they work as intended. However my game script is not running when the game starts. It is stored in serverscriptservice. It runs when executed through the console command line. Any help?

-----------------------
--- GLOBAL VARIABLES --
-----------------------
timer = 150


-----------------------
--- MAP FUNCTIONS -----
-----------------------
function TestMap()
	testmap = game.ServerStorage.TestMap:Clone()
	spawn1 = Instance.new("SpawnLocation")
	spawn1.AllowTeamChangeOnTouch = false
	spawn1.TeamColor = "Lime Green"
	spawn1.CanCollide = false
	spawn1.Anchored = true
	spawn1.Transparency = 1
	spawn1.Position = testmap.Spawns.innocent.Position
	spawn1.Parent = testmap
	spawn2 = Instance.new("SpawnLocation")
	spawn2.AllowTeamChangeOnTouch = false
	spawn2.TeamColor = "Bright Blue"
	spawn2.CanCollide = false
	spawn2.Anchored = true
	spawn2.Transparency = 1
	spawn2.Position = testmap.Spawns.sheriff.Position
	spawn2.Parent = testmap
	spawn3 = Instance.new("SpawnLocation")
	spawn3.AllowTeamChangeOnTouch = false
	spawn3.TeamColor = "Really Red"
	spawn3.CanCollide = false
	spawn3.Anchored = true
	spawn3.Transparency = 1
	spawn3.Position = testmap.Spawns.kidnapper.Position
	spawn3.Parent = testmap
end

function remTestMap()
	testmap:Destroy()
end

-----------------------
--- GAME FUNCTIONS ----
-----------------------
function assignTeams()
	local randomPlayer = game.Players:GetPlayers()[math.random(1,#game.Teams.Innocent:GetPlayers())]
	randomPlayer.Team = "Really Red"
	game.Workspace.Kidnapper.Value = randomPlayer.Character
	local kidnapper = game.ServerStorage.Kidnap:Clone()
	kidnapper.Parent = randomPlayer.Backpack
	local randomPlayer2 = game.Players:GetPlayers()[math.random(1,#game.Teams.Innocent:GetPlayers())]
	randomPlayer2.Team = "Bright Blue"
	local gun = game.ServerStorage.Revolver
	gun.parent = randomPlayer2.Backpack
end

---------------------
--- COUNT PLAYERS ---
---------------------
--[[while true do
local players = game.Players:GetPlayers()
playerCount = #players
wait(0.3)
end]]
-----------------------
---   START GAME  -----
-----------------------
while true do
	print("line1")
	wait(0.1)
	local playerCount = #game.Players:GetPlayers()
	if playerCount >= 3 then
	print("game starting")
	assignTeams()
	game.Workspace.Spawns:Clone().Parent = game.ServerStorage
	game.Workspace.Spawns:Destroy()
	TestMap()
		for _,players in pairs(game.Players:GetPlayers()) do
    		players.Character.Humanoid.Health = 0
		end
	wait(timer)
	remTestMap()
		for _,players in pairs(game.Players:GetPlayers()) do
    		players.TeamColor = BrickColor.new("Lime Green")
			game.ServerStorage.Spawns:Clone().Parent = game.Workspace
		end
	else
		for _,players in pairs(game.Players:GetPlayers()) do
    	players.PlayerGui.GameGui.Frame.TextLabel.Visible = true
		end
	print("not enough players")
	end
	wait(4.9)
end

6 comments

0

are you sure it is in server script service?

0

it is

0

does it print "Line 1"?

0

nope it does nothing at all

0

try putting wait() at the start of the script, it does work for me sometimes

0

try putting a print("Script started") at the first of everything so if it prints script started so it means the script in running but you made something wrong.