Datastore problem, don't know what do to do

passed value is not a function

pass a function to the Connect

Still same error nothing changed.

uhh, where exactly should I??

kinda confused.

Uhh you didn’t pass anything to the player removing, you need to pass a function to it, we just said that.

OH, I confused my self, sorry about that

Not sure if this is relevant, but you shouldn’t be saving the Player’s Children but rather getting their Player’s ID’s by using GetPlayers()

game:BindToClose(function()
	for i, v in next, game.Players:GetPlayers() do
		if v then
			Set(v)
		end
	end
end)
Players.PlayerRemoving:Connect(Set)

Still error

whenever you connect an event you need to pass a function to run, in this case I’m pretty sure you want to run the Set function

game.Players.PlayerRemoving:Connect(Set)


All get players does different is get the Player Objects that are parented to game.Players instead of all the children. If he doesn’t put any other objects in game.Players he’ll be fine.

What line is the error on, can you provide a screenshot

error gone, But no data is saved

Error gone, But no data is saved, uh @JackscarIitt @elonrocket ???

Should probably implement a couple of print() statements then to debug when the Data gets Saved, or check that API Services are still enabled or something

Using roblox it’s self so not to do with studio API

So would this work?

game:BindToClose(function()
	for i, v in next, game:GetPlayers() do
		if v then
			Set(v)
		end
	end
end)

Okay I found a vital mistake which you won’t notice until multiple people start playing, these same variables will be set for any player that joins the game.

Example if player1 joins the game and sets “dataloaded” to true, then when player2 joins the game “dataloaded” will also be set to true.

This will have for any kind of debounce variable you make on the server for multiple players, the way you get around it is by making a table and using the player Instance as the key

local dataloaded = {}

-- then when player data loads
dataloaded[player] = true

no GetPlayers is not a function of DataModel
you would have to do

game.Players:GetPlayers
3 Likes

Thanks a lot, give me a min, I’ll try and implement this.

Should I keep tries as it is? or will that have to be table as well?

it would have to be a table, anything that you want to have different values for different players (any kind of debounce) you will need to use a table.

On the client you wouldn’t need to use tables most of the time because you are just working with LocalPlayer so you can have something like

local debounce = false

Sometimes roblox studio can’t save the data correctly, but you could try this.

local RunService = game:GetService("RunService")
game:BindToClose(function()
	if (RunService:IsStudio())then
		wait(3)
	else
		for i, v in next, game:GetPlayers() do
			if v then
				coroutine.wrap(Set)(v) -- creates a new thread, to avoid that the repeat until affects the loop and all the players manage to save their data without having to wait.
			end
		end
	end
end)

This is only to improve saving when shutting down the game or exiting roblox studio test mode.

3 Likes

I’m having the same problem, maybe there are things that I did that would work for you (I’m having a problem of data not saving)

Post