#unknown user error

1 messages · Page 1 of 1 (latest)

sullen silo
#

when i try to use my new ban system it says the user is unknown

local button = script.Parent
local id = button.Parent.TextID.Text
local numberID = tonumber(id)
local reason = button.parent.TextReason.Text
local privreason = button.parent.PrivTextReason.Text
local duration = button.parent.TextDuration.Text
local AltBan = button.parent.TextAltban.Text

local Players = game:GetService("Players")


button.MouseButton1Click:Connect(function()
    if numberID then
        Players:BanAsync({
            UserIds = {numberID},
            ApplyToUniverse = true,
            Duration = duration,
            DisplayReason = reason,
            PrivateReason = privreason,
            ExcludeAltAccounts = AltBan,
        })
        print("Banned ".. id "time:".. duration "reason:".. reason "priv reason".. privreason "alt ban:".. AltBan)
    else
        local numberedID = Players:GetUserIdFromNameAsync(id)
        Players:BanAsync({
            UserIds = {numberedID},
            ApplyToUniverse = true,
            Duration = duration,
            DisplayReason = reason,
            PrivateReason = privreason,
            ExcludeAltAccounts = AltBan,
        })
        print("Banned ".. id "time:".. duration "reason:".. reason "priv reason".. privreason "alt ban:".. AltBan)
    end
end)

any solution? did i do something wrong?

wintry pebbleBOT
#

studio** You are now Level 2! **studio

junior slate
#

The issue came from two main problems. First, you used button.parent with a lowercase “p”, but in Roblox it must be Parent with a capital “P”. Second, your print statement was broken because you didn’t concatenate all the parts with .., which caused a syntax error. Once those two things are fixed, the script works normally.

cyan raptor
#

In local numberid change it on player name maybe

sullen silo
#

ok thx imma test it

#

it doesnt work still

#

i think the problem is coming from the function that changes username to id

cyan raptor
#

If Im right in this () should be username

sullen silo
#

ok

#

it is the username

midnight lantern
sullen silo
#

ok

midnight lantern
#

also you should prolly pcall

sullen silo
#

wdym from pcall

sullen silo
#

the error is that its not getting numberedID or the Players:GetUserIdFromNameAsync(id) function

midnight lantern
#

what is otuput

sullen silo
#

ok

#

wait

#

dude

#

numberid is just to check if the id is a number

#

so

#

its basically what i typed in there

sullen silo
midnight lantern
sullen silo
#

yes its the users id

midnight lantern
sullen silo
#

numberid is number

#

dude u confused me

midnight lantern
#

you cant pass in an id

sullen silo
#

THATS WHAT IM DOING

midnight lantern
#

you just said id is a number

sullen silo
sullen silo
#

numberID checks if the local id is a number

midnight lantern
#

so id a number or not rn

sullen silo
#

its not

#

im passing in username

midnight lantern
sullen silo
#

ok im still seraching for pcall in the link u gave me

#

can u explain it to me i couldnt find it

wintry pebbleBOT
#

studio** You are now Level 3! **studio

sullen silo
#

nvm

#

searched it

#

found out

#
local function Players:GetUserIdFromNameAsync(id)
    return Players:GetUserIdFromNameAsync(id)
end

local success, errormessage = pcall(numberedID())

if success then
    print("Success")
else
    warn("error:", errormessage)
end

is this right?

midnight lantern
sullen silo
#

ok

#

btw u forgot to close the (

#

ok so like this?

#
local success, error
repeat
    success, error = pcall(function()
        Players:GetUserIdFromNameAsync(id)
    end)
until success

if success then
    print("success")
else
    warn("error:", error)
end
sullen silo
#

ok

sullen silo
#

your script is supper laggy dude

#

im just gonna find a way

midnight lantern
#

instead of looping, you could add a retry counter instead

sullen silo
#

even ai cant fix it...

#

ddang

#

im gonna go search the web

midnight lantern
sullen silo
#

ok

#

wait where?

hasty kite
#
local success, error

repeat
    success, error = pcall(function()
        Players:GetUserIdFromNameAsync(id)
    end)
until success

print("success")

so this is the same

sullen silo
#

ok so what do i do man

#

this is the script

#
local button = script.Parent
local id = button.Parent.TextID.Text
local numberID = tonumber(id)
local reason = button.Parent.TextReason.Text
local privreason = button.Parent.PrivTextReason.Text
local duration = button.Parent.TextDuration.Text
local AltBan = button.Parent.TextAltban.Text

local Players = game:GetService("Players")


button.MouseButton1Click:Connect(function()

    if numberID then
        print(numberID)
        print(id)
        Players:BanAsync({
            UserIds = {numberID},
            ApplyToUniverse = true,
            Duration = {duration},
            DisplayReason = {reason},
            PrivateReason = {privreason},
            ExcludeAltAccounts = {AltBan},
        })
        print("Banned ".. id, "time:".. duration, "reason:".. reason, "priv reason".. privreason, "alt ban:".. AltBan)
    else
        local numberedID = Players:GetUserIdFromNameAsync(id)
        print(numberedID)
        print(id)
        
        Players:BanAsync({
            UserIds = {numberedID},
            ApplyToUniverse = true,
            Duration = {duration},
            DisplayReason = {reason},
            PrivateReason = {privreason},
            ExcludeAltAccounts = {AltBan},
        })
        print("Banned ".. id, "time:".. duration, "reason:".. reason, "priv reason".. privreason, "alt ban:".. AltBan)
    end
end)

local success, error
repeat
    task.wait()
    success, error = pcall(function()
        Players:GetUserIdFromNameAsync(id)
    end)
until success

if success then
    print("success")
else
    warn("error:", error)
end
#

this is line 27

local numberedID = Players:GetUserIdFromNameAsync(id)
hasty kite
#

local numberedID = Players:GetUserIdFromNameAsync(id)
id need to be a username

#

not a user id idk if its comming from that

sullen silo
#

it is my username

hasty kite
#

real username not the display one

sullen silo
#

ik

#

the real username

hasty kite
#

bruh idk

#

im at school right now

sullen silo
#

ok...

#

weirdest bug ive ever seen tbh

limpid moon
#

?

#

ur trying to get the id from an id

sullen silo
#

yes

#

banasync cant ban with the username

#

it has to be the id

limpid moon
#

local numberedID = Players:GetUserIdFromNameAsync(id) the error is showing about this line

#

@sullen silo

sullen silo
#

yes

wintry pebbleBOT
#

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

hasty kite
#

ow

#

you need to convert id to number

#

Players:GetUserIdFromNameAsync(tonumber(id)) bc you take it with .Text so its a string

#

and it need to be a number

sullen silo
#

oh

#

so that was it

#

such a simple thing toke 3 hours

#

my time...

#

wait lemme test

sullen silo
#

it doesnt work

limpid moon
#

cuz its not an pcall error ur using the function wrong

sullen silo
#

ok then give me the right one dude

limpid moon
#

why

sullen silo
#

because i dont know what to do anymore

limpid moon
#

did you make the script or nah?

#

myb learn what it does first

sullen silo
#

ik what it does but ik nothing about pcall

limpid moon
#

check a video about it

#

by brawldev

sullen silo
#

ok im using banasync() btw

limpid moon
#

and where is it said in the console its cau sing an error

sullen silo
limpid moon
#

its the same class method as the other one

#

so u need to pass a name in not an id?

sullen silo
#

if i pass a username it turns it into the player id

limpid moon
#

do u have api services enabled?

#

in the settings

sullen silo
#

lemme check

#

ok i truned it on

#

it gives the error still

#

wait

#

it gave a new error now

limpid moon
#

ok

#

u have the argument mixed up

#

local numberedID = Players:GetUserIdFromNameAsync(numberID)

#

but why are you running any of that other code

#

u already have the player id

sullen silo
#

uh

#

its because you need the number id

#

and if i put the username

#

it wont work

#

so im trying to get the id from the username

limpid moon
#

lol

#

its need the players name not the id

sullen silo
#

ok so im putting the username then it turn it to a id and then it doesnt work?

limpid moon
#
local button = script.Parent
local id = button.Parent.TextID.Text
local numberID = tonumber(id)
local reason = button.Parent.TextReason.Text
local privreason = button.Parent.PrivTextReason.Text
local duration = button.Parent.TextDuration.Text
local AltBan = button.Parent.TextAltban.Text

local Players = game:GetService("Players")


button.MouseButton1Click:Connect(function()
        Players:BanAsync({
            UserIds = {numberID},
            ApplyToUniverse = true,
            Duration = {duration},
            DisplayReason = {reason},
            PrivateReason = {privreason},
            ExcludeAltAccounts = {AltBan},
        })
        print("Banned ".. id, "time:".. duration, "reason:".. reason, "priv reason".. privreason, "alt ban:".. AltBan)
end)
``` this works the same
limpid moon
sullen silo
#

ok ill test

limpid moon
#

you get the user id from the name

#

Players:GetUserIdFromNameAsync()

#

thats why you put the pcall

sullen silo
#

as i thought it didnt work dude

#

banasync need the ID

#

not the USERNAME

limpid moon
#

?

#

i was talking about the error

#

that was already good

#

@sullen silo

sullen silo
#

oh ok

wintry pebbleBOT
#

studio** You are now Level 5! **studio

sullen silo
#

lemme test id

limpid moon
#

ok

#

you also said id can be not a number

#

so that would make an error

sullen silo
#

wait a minute

#

so

#

im rn using a id

#

and its thinking its not a number?

#

what

limpid moon
#

no

#

it would cause an error

limpid moon
#

u just made it turn it into a number but u cant do that cause its a string

#

so if u want to store the username and id seperately dont do that in a text label

sullen silo
#

uh ok so how do i do that?

limpid moon
#

i dont know how why are you setting the guis text to an id which you got from somewhere and then get that same id in ur code from the text?

#

wheres the id coming from in the text?

#

also what button are you clicking if the player is already banned

#

refactor ur system design a little

sullen silo
sullen silo
limpid moon
#

ur getting the id from the text label so change like where you store it first definitely not in textlabel

#

why did you make that code if the id was always random

sullen silo
#

its my first time using banasync

#

idk

#

wait

#

someone has a video for it

#

with gui

#

:O

limpid moon
#

just use a remote function and send the id over in a server script which uses the ban async
in the local script where ur getting the id and setting it to the text

#

cool

sullen silo
#

i have no idea how to use remote function and stuff

limpid moon
#

u send data over from the client side to the server side by doing remoteevent:fireserver(ur data)

#

and on the server u receive it by doing remoteevent.onserverevent(data)

#

and u set the id like that

sullen silo
#

ohh

#

so the ban stuff have to be on another script?

limpid moon
#

it doesnt you receive the id from the client

sullen silo
#

can u give me a example code?

limpid moon
#

wait

sullen silo
#

ok

limpid moon
#
-- client script
local Rs = game:GetService("ReplicatedStorage")
local Event = Rs:WaitForChild("eventname")
local id = 123456789

Event:FireServer(player, id) -- the client player to which you fire to

-----------------
-- server script
local Rs = game:GetService("ReplicatedStorage")
local Event = Rs:WaitForChild("eventname")

Event.OnServerEvent:Connect(function(id) -- doesnt need player
  Players:BanAsync({
            UserIds = {id},
            ApplyToUniverse = true,
            Duration = {duration},
            DisplayReason = {reason},
            PrivateReason = {privreason},
            ExcludeAltAccounts = {AltBan},
        })
        print("Banned ".. id, "time:".. duration, "reason:".. reason, "priv reason".. privreason, "alt ban:".. AltBan)
end)
#

so this should help out

sullen silo
#

ok thx

#

wait so if i give a username instead of a id it still bans the user?

limpid moon
#

it doesnt

#

i think

sullen silo
#

so i can use the function that bugs out everytime i run it on my own script on this script?

limpid moon
#

nah

#

why do you need to use it

sullen silo
#

because if i want to ban someone ill have to go and search his username on roblox

limpid moon
#

but u can ban with a user id?

#

not the username

sullen silo
#

yes

#

im too tired to work on this ban system

#

for tomorrow

limpid moon
#

i sent you all of the script

sullen silo
#

ive been here for 6 hours

#

ye ik

#

and this isnt even my game

#

my friend asked me to help...

#

imma call him

#

his not answering

#

ig im not gonna work on it

#

bye

limpid moon
#

you said youd stop 3 hours ago

#

@sullen silo

sullen silo
#

ye i forgot

#

i lost track of time

midnight lantern
#

pcall both banasync and getuserid and make sure id is spelt correctly and is a real username

#

and make sure you have players.banningenabled true