#im trying to fix an error in my code

57 messages · Page 1 of 1 (latest)

gritty berry
#

can someone please help

#

the issue is

#

the username underlined in red

#

the ones near the bottom

#

it says

#

unknown global variabel

#

variable

#

but i have it set right here

astral wing
#

thats a local variable

#

it is only available in that function

gritty berry
#

oh yeah\

#

wait

#

but then moving it out now there is another error

astral wing
#

define it outside

#

assign the value inside the function

gritty berry
#

which function

astral wing
#

onPlayerAdded

gritty berry
#

oh ok

#

wait

#

but isn't that what i just did

#

before i took it out

astral wing
#

did you define it outside the function?

#

no

gritty berry
#

i dont think this is inside any function

peak hill
astral wing
#

defining means telling the computer that a variable with a name exists

peak hill
gritty berry
#

still underlined

peak hill
#

Inside the function

#

Under the print

gritty berry
#

yeah

peak hill
#

Yes

#

Problem solved,

gritty berry
#

but username is still underlined

#

im confused

peak hill
#

Orange underline

#

Not an error

#

Just the script telling you "Hey maybe you shouldnt do that"

#

But still works

gritty berry
#

oh

#

ok

#

let me test\

#

output

#

line 31

gritty berry
#

hello?

unkempt cedar
#
local username
Players.PlayerAdded:connect(function(plr)
username = plr.Username
End)
#

💀

#

@gritty berry

short hound
#

you cannot just ask for a player name anywhere