What i’m trying to do is to debounce only for player using Table.Insert .
Script :
local dataLoaded = {}
for i,v in pairs(plr.UserId:GetChildren()) do
table.insert(dataLoaded, v)
print(dataLoaded)
end
Error :
ServerScriptService.Data - Store:111: attempt to index number with 'GetChildren’
D0RYU
(nici)
July 16, 2021, 5:46am
#2
the userid is literally a number, what makes you think it has any children?
1 Like
I see however i change my code and there’s new error .
Script :
local dataLoaded = {}
for i,v in pairs(plr.UserId) do
table.insert(dataLoaded, v)
print(dataLoaded)
end
Error :
ServerScriptService.Data - Store:111: invalid argument #1 to ‘pairs’ (table expected, got number)
This is an xy problem . What are you actually trying to do here, in detail?
1 Like
D0RYU
(nici)
July 16, 2021, 5:50am
#5
you can’t use pairs() with a number
as it says it expects a table!
Then how can i make table not getting that error ?
D0RYU
(nici)
July 16, 2021, 5:58am
#7
I mean you don’t have much information here
Information : What i’m trying to do is to make an debounce without affecting other players
Example :
Player 1 – Set to true
Player 2 – Set to false
That’s why i want it to make in table.
D0RYU
(nici)
July 16, 2021, 6:01am
#9
DylTheDeveloperX:
debounce
a debounce is literally to stop code from running too much
giving players a bool isn’t really a debounce
and what do you mean by “without affecting other players”
Yes i know.
If i do this :
local DataLoaded = false
then my script make it True then it will stop to work because it set to true. so i want to do is Make an table which only for client or players so it will still continue to work.
D0RYU
(nici)
July 16, 2021, 6:10am
#11
local Table = {}
for i, v in pairs(game.Players:GetChildren()) do
Table[v] = false -- set false to whatever the Boolean is
end
I guess this would make a table with every player and give them a bool that is equal to false
if you wanted to change a player you could do this
Table[Player] = true -- Player would be the player instance and the true is the Boolean
hope this helped, still kind of confused on what you want
1 Like
Uh i said it only set for player not at all so the script can still continue to change the value.
You keep saying the same thing when people ask for more details about what you’re trying to do.
At a high level: what are you trying to do? What is your end goal? What are you trying to make a table of, and why?
Like when player joins it will be set to true however the other player when they join the server it makes to true so the server can till set it and not to lock it just like this.
Example :
local DataLoaded = false
playeradded:Connect(function()
DataLoaded = true
see it will make the DataLoaded set to true however i only want to set the dataLoaded only on player.
D0RYU
(nici)
July 16, 2021, 6:34am
#16
local DataLoaded = {}
PlayerAdded:Connect(function(Player)
DataLoaded[Player] = true
end
is this what you want?
1 Like
I see it’s like that but my last question is did it insert to table?
like Player.UserId = true
D0RYU
(nici)
July 16, 2021, 6:45am
#18
oh if you want to do the userid instead of the instance try this code
local DataLoaded = {}
PlayerAdded:Connect(function(Player)
DataLoaded[Player.UserId] = true
end
printing Dataloaded would be like this
{
[123456] = true
}
the 123456 is the UserId
1 Like