#Each 1000 studs you get 10 cash, but the 14 line cant index nil with leaderstats, please help me!
78 messages · Page 1 of 1 (latest)
is it possible that it enters the if statement without having a player?
since getting the player is conditional
Player only gets declared on the touched event. Yet the while loop will run before that
Just check if there's a player
Its fine lmao
"if while true do then", like that?
no
if player then
-- stuff
else
print("plr notloaded")
end
dont even need else but yeah
yeah just for debug
also if u wanna make ur code shorter u can do player.leaderstats.Cash.Value += 10 instead of player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 10
no difference, just more readable imo
Alright
remembering that you need to declare the leaderstats before calling it I think
You’re not calling it directly, you’re navigating from player to leaderstats so it’s not needed
Do i put if player then instead of while true do
nah just check inside of the while loop,
if player then```
** You are now Level 3! **
etc
between while true loop and if player?
yes you need a wait statement outside of the if statements scope
yeah i've done that
and still getting the error?
right
huh
not sure if it works in lua but
u might have to indent the code after if player then
haven't been coding on roblox for long
oh yeah
so not sure
nothing happens
you're right
the int value doesn
count
neither i get the money
or miles
the if statement is only preventing the error, it's not grabbing the player for you
yeah
atm the only way to grab the parent is by touching that part or w/e
u can use a few print statements to find out where the program aint working
nobody really neither posts about drive to get cash on the roblox studio page
yh
hard getting help
is this your first game?
oh no no
i've been on for like 3 years
i do gui and icons and thumbnails
that
im not the best at scripting
ay me neither dw
lol
but yeah, print out player, metersdriven.value and script.parent.velocity.magnitude
u should be able to figure out on ur own from here but ping me if u cant
ight
fixed it