Scripts not running in game

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

I’m making a game where you get teleported to a different place. It uses a datastore when you join the game to see if you are newly joining, or if you are coming back from the place.

  1. What is the issue? Include screenshots / videos if possible!

When I test it in studio, it works fine and all the code works, but in the actual game, it’s not even outputting the prints that I used to test it that are at the beginning of the script.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I thought it might have been an error with my scripts, but I placed a print at line 1 of the script and it still doesn’t print in-game. I’ve tried looking everywhere for solutions but found nothing.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Script inside of ServerScriptService:

game.Lighting.ClockTime = 6
game.Lighting.FogEnd = 250
print("eee")
repeat wait() until script ~= nil
print("aaa")

local DataStoreService = game:GetService("DataStoreService")

local WhereToSpawnStore = DataStoreService:GetDataStore("WhereToSpawnStore")

game.Players.PlayerAdded:Connect(function(player)
	local data
	local WhereToSpawn

	local success, result = pcall(function()
		data = WhereToSpawnStore:GetAsync(player.UserId .. "-WhereToSpawn")
	end)

	if success then
		print("Loaded successfully")
		WhereToSpawn = data
		if WhereToSpawn == nil then
			WhereToSpawn = 0
			print("Created new table")
		else
			print(WhereToSpawn)
		end
	else
		print("Error loading data")
		warn(result)
	end
	

	
	if WhereToSpawn ~= 0 then
		local success, result = pcall(function()
			WhereToSpawnStore:SetAsync(player.UserId .. "-WhereToSpawn", 0)
		end)

		if success then
			print("Saved successfully")
			print(WhereToSpawn)
		else
			print("Error saving data")
			warn(result)
		end
		
		if WhereToSpawn == 1 then
			game.StarterPlayer.StarterPlayerScripts:WaitForChild("LocalEvents")
			game.ReplicatedStorage:WaitForChild("LoadRemove"):FireClient(player, 1, 1)
		end
		print(player.Character.Parent)
		player.Character:WaitForChild("HumaniodRootPart").Position = game.Workspace:WaitForChild("ReturnSpawn" .. tostring(WhereToSpawn)).Position
	end
	print("asdawsadwaasdqawdasdwadsd")
end)

In game:

In studio:
print

4 Likes

Can you try these things:

  1. make sure you’re published to your latest version, you probably are but worth checking anyway
  2. use the developer console and try and print out the script just to check if it does exist in game (and maybe check that it is not being disabled too)
2 Likes

I tried both, and it isn’t being disabled

1 Like

Have you tried right clicking on the script tab and check if its edits are applied?
image

2 Likes

Uhh, I just changed something in a print and tried testing it again today and now it’s working?? Idk maybe it was just bugged yesterday, but now it’s working, so I guess that may have fixed it.

1 Like