You can write your topic however you want, but you need to answer these questions:
- 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.
- 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.
- 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: