62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 28 Feb 2016 03:02 PM |
'Attempt to compare number with nil'
The error I'm getting from the client. Here's the RemoteFunction's script, which is in the Workspace. When I add a print in here it runs, if I put the print in the if statement it doesn't run. 'player' is a non-nil string containing the player's name. And in the server storage there is a folder that's named the player's name. And I even checked it myself -- That folder isn't nil! So why isn't this code running? It's a server script, so it should have access to ServerStorage.. FE is on.
wait() function script.Parent.OnServerInvoke(player) --Used to get the player's cash. local money = game.ServerStorage:FindFirstChild(player) if money then return money.Cash.Value end end |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 28 Feb 2016 03:08 PM |
LOL.
local money = game.ServerStorage:FindFirstChild(player) print(game.ServerStorage.Player.Name) if money then return money.Cash.Value end
It doesn't print nil, but for some reason money is nil. explanation pls |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 03:09 PM |
| Do print(money), wouldn't be surprised if that was the problem. Also, make a custom waitforchild function, and replace it with findfirstchild (It's useful in a lot of contexts) |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 28 Feb 2016 03:10 PM |
I did that, as I already stated. And it prints 'Player' (The name of the player, it isn't a instance, it's a string. I double-checked)
|
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 28 Feb 2016 03:12 PM |
| Does FindFirstChild not work with FE? This or some other thing I never knew didn't work with FE. |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 03:14 PM |
| game.ServerStorage:FindFirstChild(player.Name) |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 28 Feb 2016 03:15 PM |
| player is a String. Not an object. |
|
|
| Report Abuse |
|
|
|
| 28 Feb 2016 03:18 PM |
No its not. http://wiki.roblox.com/index.php?title=API:Class/RemoteFunction/OnServerInvoke |
|
|
| Report Abuse |
|
|
62GB
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 4157 |
|
|
| 28 Feb 2016 03:20 PM |
| Wow gg. I was actually sending over the player's name cause I thought it didn't automatically send the player over. Thanks. |
|
|
| Report Abuse |
|
|