#output error after following tutorial - NEW TO SCRIPTING

1 messages · Page 1 of 1 (latest)

sharp hamlet
#

The code causing the error is:
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
The output is
Players:GetUserIdFromNameAsync() failed: Unknown user
What to do? anyone know?

delicate notch
# sharp hamlet The code causing the error is: ```local userName = game.Players:GetN...

print data.key and see what u get its saying unknown user since u are putting an invalid key.

(Also not to be that guy but avoid any of those "Beginner" tutorials where they show u how to make a combat system or anything similar they are traps that just waste ur time (no disrespect to the creators tho). If I were u id try to do small projects when starting out like changing a parts color or moving it.)

sharp hamlet
#

it just didnt print anything and thanks for that advice

#

also its working on a diff baseplate i have just not on the main one

#

if that changes anything

delicate notch
#

whats the tutorial ur following out of curiosity

sharp hamlet
delicate notch
#

oh yea devking yea hes goated ok thats actually a good tutorial

sharp hamlet
#

yhyh all the other tuts told me to download models but i aint doin that

vale ferryBOT
#

studio** You are now Level 4! **studio

delicate notch
#

just make sure u understand the code dont be afraid to use chatgtp to help u explain code lines just dont use it to code for you thats cringe

delicate notch
sharp hamlet
#

alr alr

sharp hamlet
delicate notch
sharp hamlet
#

bit too long for disc sry

#

ignore the that was before i converted to a file

#

"```"*

delicate notch
#

yea u do lua code here

#

oh im dumb I mean 3 then write lua then close with 3

#

BRO

#

use 3 of ` then type lua close it with 3 of them again

sharp hamlet
delicate notch
#

"lua "

sharp hamlet
#
print("this a test")```
#

ahhh i see

delicate notch
#

ok yea nice

#

just post the code in sections its fine

sharp hamlet
#
local DataStoreService = game:GetService("DataStoreService")
local KillsLeaderboard = DataStoreService:GetOrderedDataStore("KillsLeaderabord")

local function updateLeaderboard()
    local success, errorMessage = pcall(function()
        local Data = KillsLeaderboard:GetSortedAsync(false, 5)
        local KillsPage = Data:GetCurrentPage()
        for Rank, data in ipairs(KillsPage) do
            local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
            local Name = userName
            local Kills = data.value
            local isOnLeaderboard = false
            for i, v in pairs(game.Workspace.GLOBALLeaderboard.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()) do
                if v.Player.Text == Name then
                    isOnLeaderboard = true
                    break
                end
            end```
#

???

#

it wont go thru

delicate notch
#

wait take a screenshot

#

thats probs easier ngl

sharp hamlet
#

yh hold up

delicate notch
#

oh I already see the problem

sharp hamlet
#

?? what i do

delicate notch
#

ur running this game in studio u might think its using ur actual player id but its using the test players id which is 1

#

thats why it works when u play it in the actual game

#

so the code works it just doesnt work in studio. (Well it does work in studio but ur saving data for the test player which is id 1 so its still on the database its just kinda useless

sharp hamlet
#

still not working 😔

sharp hamlet
delicate notch
sharp hamlet
#

the other baseplate i refollowed the tutorial to see if i did anything wrong

#

i followed it and everything worked perfectly

#

so i copied that into what i'll call the main game

#

and im getting that output

delicate notch
#

hmmmmmmmmmmmmmmmm they both worked while in studio right?

sharp hamlet
#

other baseplate worked in studio

#

main game didnt

delicate notch
#

ok can u try printing out this line: game.Players:GetNameFromUserIdAsync(tonumber(data.key))

#

its in the updateleaderboard function

latent swallow
#

Aye bro i can change ur baseplates color dw

sharp hamlet
delicate notch
sharp hamlet
#

still nothing 😔

delicate notch
#

is it still giving u request added to queue error?

#

are u still able to add people to ur roblox games or did they remove that cause of id verification I would probs be easier if I take a look

delicate notch
#

yea lowkey it might just be easier if I take a look at the game

sharp hamlet
#

alr whats ur user

delicate notch
#

Rowdy_Monkey

sharp hamlet
#

accept

delicate notch
#

whats ur user

#

oh I see its joyus

#

k u can add me to ur game now

#

ok im in ill see if I can see the problem

sharp hamlet
#

alr ty

delicate notch
#

yea see here the problem is that we have -1 and -2 then we have ur player id it errors since -1 and -2 is an invalid user since u used the test players

#

BOOYAH it works

sharp hamlet
#

YOOO MY GOAT

delicate notch
#

I just ran this command:

KillsLeaderboard:RemoveAsync(-1)
KillsLeaderboard:RemoveAsync(-2)

sharp hamlet
#

my goat bro tysm

delicate notch
#

np bro goodluck on ur scriping journey 👍

latent swallow
#

Inv me to your scripting journey bro 🙏

sharp hamlet
latent swallow
#

W