Anyone know the error in this script?

In the beggining of each of that Scripts add a task.wait(10)

1 Like
local DSS = game:GetService("DataStoreService")
local Debris = game:GetService("Debris")




--EVENTS

--EVENTS





local pointdss = DSS:GetDataStore("Points")
local timedss = DSS:GetDataStore("TimeReseter")
local jaileddss = DSS:GetDataStore("Jailed")
local botmodule = require(game.ReplicatedStorage.Modules.BotHandler)
local maxrank = 30

function counttime(timevalue,pointsval)
	while true do
		wait(1)
		if timevalue then
			timevalue.Value += 1
			local success,errormessage = pcall(function()
				if timevalue.Value == 2400 then
					pointsval.Value += 1
				end
			end)
		end
	end
end
function gettimeremaining()
	local remainingtime = 24000 - (os.date("*t", os.time()).hour)
	return remainingtime
end

game.Players.PlayerAdded:Connect(function(player)
	local inventory = Instance.new("Folder",player)
	inventory.Name = "leaderstats"
	local points = Instance.new("IntValue",inventory)
	points.Name = "Points"
	local cash = Instance.new("IntValue",inventory)
	cash.Name = "Cash"
	local secondsplayed = Instance.new("IntValue",player)
	secondsplayed.Name = "timeplayed"
	
	--inventory
	local slots = Instance.new("Folder",player)
	slots.Name = "Slots"
	local s0 = Instance.new("StringValue",slots)
	s0.Name = "Slot0"
	local s1 = Instance.new("StringValue",slots)
	s1.Name = "Slot1"
	local s2 = Instance.new("StringValue",slots)
	s2.Name = "Slot2"
	local s3 = Instance.new("StringValue",slots)
	s3.Name = "Slot3"
	local s4 = Instance.new("StringValue",slots)
	s4.Name = "Slot4"
	local s5 = Instance.new("StringValue",slots)
	s5.Name = "Slot5"
	local s6 = Instance.new("StringValue",slots)
	s6.Name = "Slot6"
	local s7 = Instance.new("StringValue",slots)
	s7.Name = "Slot7"
	local s8 = Instance.new("StringValue",slots)
	s8.Name = "Slot8"
	
	local toolinventory = Instance.new("Folder",player)
	toolinventory.Name = "Tools"
	
	
	--EVENTS
	--EVENTS
	
	
	local pointsdata
	local cashdata
	local timedata
	local timermdata
	local jaileddata
	local success,errormessage = pcall(function()
		pointsdata = pointdss:GetAsync(player.UserId.."-pts")
		cashdata = pointdss:GetAsync(player.UserId.."-cash1")
		timedata = timedss:GetAsync(player.UserId.."-time")
		timermdata = timedss:GetAsync(player.UserId.."-timeremaining")
		jaileddata = jaileddss:GetAsync(player.UserId.."-jailed")
	end)
	if success then

		if pointsdata ~= nil then
			points.Value = pointsdata
		end
		if cashdata ~= nil then
			cash.Value = cashdata
		end
		if timedata ~= nil then
			secondsplayed.Value = timedata
		end
		if timermdata ~= nil then
			local currentrmhours = gettimeremaining()
			if timermdata > currentrmhours then
				secondsplayed.Value = 0
			end
		end
		if jaileddata ~= nil then
			if jaileddata.Jailed == true then
				local timejailed = tick() - jaileddata.Time
				if timejailed < 1800 then
					local tag = Instance.new("IntValue",player)
					tag.Name = "Jailed"
					tag.Value = jaileddata.Time
					Debris:AddItem(tag,timejailed)
					print(player.Name.." has been jailed for "..timejailed.." seconds")
				end
			end
		end
		print(player.Name.."'s data has loaded")
	else
		print(player.Name.."'s data had error loading")
		warn(errormessage)
	end
	
	spawn(function()
		counttime(secondsplayed,points)
	end)
end)

game.Players.PlayerRemoving:Connect(function(player)
	local remaininghours = gettimeremaining()
	local success,errormessage = pcall(function()
		pointdss:SetAsync(player.UserId.."-pts",player.leaderstats.Points.Value)
		pointdss:SetAsync(player.UserId.."-cash1",player.leaderstats.Cash.Value)
		timedss:SetAsync(player.UserId.."-time",player.timeplayed.Value)
		timedss:SetAsync(player.UserId.."-timeremaining",remaininghours)
		
		if player:FindFirstChild("Jailed") then
			local jaildata = {
				Jailed = true,
				Time = player.Jailed.Value
			}
			jaileddss:SetAsync(player.UserId.."-jailed",jaildata)
		end
		
	end)
	if success then
		print(player.Name.."'s data has saved")
	else
		print(player.Name.."'s data had error saving")
		warn(errormessage)
	end
	game.ReplicatedStorage.REvents.reloadlb:FireAllClients()
end)


game:BindToClose(function()
	for i, v in pairs(game.Players:GetPlayers()) do
		v:Kick("Game is Shutting Down. Saving Data. . .")
	end
	wait(1)
end)
1 Like

Finally got it:) Thanks for your patience! The ```

1 Like

Yeah it was a pain copying and pasting it since I am currently typing on my phone

1 Like

Try tô add a task.wait(10) in the beggining of each script

1 Like
 09:28:42.319  bosspapaboss committed a new version of script ReplicatedStorage.Modules.GroupRankMorph  -  Studio
  09:28:43.818  EXO @ 16 janv. 2023 09:28 auto-recovery file was created  -  Studio
  09:28:51.559  authentication successful  -  Server - MainModule:21
  09:28:51.604  :: Adonis :: Loading...  -  Server
  09:28:51.605  Requiring asset 7510592873.
Callstack:
Workspace.Adonis_Loader.Loader., line 111
  -  Studio
  09:28:53.786  authentication successful  -  Server - MainModule:24
  09:28:56.906  :: Adonis :: Requiring Alerts Module by ID; Expand for module URL >  table: 0x74b00edded731a92  -  Server
  09:28:56.906  Requiring asset 8096250407.
Callstack:
required_asset_7510592873.MainModule.Server.Server, line 402 - require
required_asset_7510592873.MainModule.Server.Plugins.Urgent_Messages, line 17
required_asset_7510592873.MainModule.Server.Shared.Service, line 118 - taskFunc
required_asset_7510592873.MainModule.Server.Shared.Service, line 134 - TrackTask
required_asset_7510592873.MainModule.Server.Server, line 217 - LoadModule
required_asset_7510592873.MainModule.Server.Server, line 697 - __call
Workspace.Adonis_Loader.Loader., line 112
  -  Server
  09:28:59.207  :: Adonis :: Loading existing player: bosspapaboss  -  Server
  09:29:00.235  enabled  -  Client - ShiftScript:29
  09:29:01.132  Requiring asset 2162513106.
Callstack:
ServerScriptService.ToolScripts.Guns.gunServer.MainModule, line 79
  -  Server - MainModule:79
  09:29:01.299  :: Adonis :: Loading Complete; Required by 0.3879432180639344.Loader.Loader  -  Server
  09:29:01.390  Got Division List!  -  Client - CoreScript:25
  09:29:01.390  Child Added: United States Military  -  Client - CoreScript:151
  09:29:01.390  Child Added: United States Marines  -  Client - CoreScript:151
  09:29:01.390  Child Added: United States Navy  -  Client - CoreScript:151
  09:29:01.391  Child Added: Officers  -  Client - CoreScript:151
  09:29:01.391  Child Added: War College  -  Client - CoreScript:151
  09:29:01.391  Child Added: Military Police  -  Client - CoreScript:151
  09:29:01.687  bosspapaboss joined  -  Server - MainModule:82
  09:29:01.687  character exists, building rig  -  Server - MainModule:85
  09:29:05.239  Infinite yield possible on 'Players.bosspapaboss.leaderstats:WaitForChild("Points")'  -  Studio
  09:29:05.240  Stack Begin  -  Studio
  09:29:05.240  Script 'Players.bosspapaboss.PlayerGui.Controller', Line 6  -  Studio - Controller:6
  09:29:05.240  Stack End  -  Studio
  09:29:05.240  Infinite yield possible on 'Players.bosspapaboss.leaderstats:WaitForChild("Points")'  -  Studio
  09:29:05.240  Stack Begin  -  Studio
  09:29:05.240  Script 'Players.bosspapaboss.PlayerGui.MainMenuGui.TopFrame.Main', Line 5  -  Studio - Main:5
  09:29:05.240  Stack End  -  Studio
  09:29:11.302  bosspapaboss's data has loaded  -  Server - PlayerHandler:120
  09:29:24.302  1111111111  -  Client - LocalScript:132
  09:29:24.361  222222222  -  Client - LocalScript:134
  09:29:27.688  building rig under characteradded  -  Server - MainModule:90
  09:29:27.793  Humanoid is not a valid member of Model "Workspace.bosspapaboss"  -  Client - Core_client:6
  09:29:27.793  Stack Begin  -  Studio
  09:29:27.793  Script 'Players.bosspapaboss.Backpack.Guard Pike.Core.Core_client', Line 6  -  Studio - Core_client:6
  09:29:27.793  Stack End  -  Studio
  09:29:27.803  enabled  -  Client - ShiftScript:29
  09:29:29.654  building rig under characteradded  -  Server - MainModule:90
  09:29:29.751  Cannot load the AnimationClipProvider Service.  -  Client - Core_client:10
  09:29:29.751  Stack Begin  -  Studio
  09:29:29.751  Script 'Players.bosspapaboss.Backpack.Guard Pike.Core.Core_client', Line 10  -  Studio - Core_client:10
  09:29:29.751  Stack End  -  Studio
  09:29:29.780  enabled  -  Client - ShiftScript:29
  09:29:32.804  Infinite yield possible on 'Players.bosspapaboss.leaderstats:WaitForChild("Points")' (x3)  -  Studio
  09:29:34.790  Stack Begin  -  Studio
  09:29:34.790  Script 'Players.bosspapaboss.PlayerGui.Controller', Line 6  -  Studio - Controller:6
  09:29:34.790  Stack End  -  Studio
  09:29:34.790  Infinite yield possible on 'Players.bosspapaboss.leaderstats:WaitForChild("Points")'  -  Studio
  09:29:34.790  Stack Begin  -  Studio
  09:29:34.790  Script 'Players.bosspapaboss.PlayerGui.MainMenuGui.TopFrame.Main', Line 5  -  Studio - Main:5
  09:29:34.791  Stack End  -  Studio
  09:29:51.618  Buttondoor is not a valid member of Folder "Workspace.Bank"  -  Server - BankHandler:23
  09:29:51.618  Stack Begin  -  Studio
  09:29:51.618  Script 'ServerScriptService.BankHandler', Line 23  -  Studio - BankHandler:23
  09:29:51.618  Script 'ServerScriptService.BankHandler', Line 108  -  Studio - BankHandler:108
  09:29:51.618  Stack End  -  Studio

I think i will defenitly need a real scripter to fix my game ngl, doing my best but aint a scripter…

You can try asking ChatGPT but i don’t know if that will help

1 Like

These errors have nothing to do with the code you provided. It’s probably another issue now…

1 Like