How could I get this to work?

“leaderstats” is supposed to be lowercase when used in this context.

Didn’t @NinjaMinion101 say that it’s capitalized + case sensitive?

Oops! This thread is kind of long, I didn’t notice that.

Edit: wait no, he’s referring to his example, not the OP.

Oh wait, I misunderstood the context of that! (the example)
I’m sorry I guess…

Hi @NoobiDerpieDev, of course.

The error says ‘attempt to index nil with WaitForChild’. This means the child of the Player, which is leaderstats in this case, is nil. It doesn’t exist (yet).

In my game, the script works so it should work in your game too.


Possible problems:

  • the Part which gives cash is not named after the owner. To check this, follow the steps below:
  1. Open Roblox Studio and test your game.
  2. Open Explorer. Drag GreyPart on BlackPart (make the script activate).
  3. What is the name of the part? If it isn’t ‘NoobiDerpieDev’, the error is caused because of another script.
  • the Script I made is not inside of the GreyPart (the part you drag on the BlackPart).

  • Problem with variable in line 3. If the script is inside of GreyPart, this line must be like below:

local GreyPart = script.Parent
  • Problem with variable in line 4. Line 4 refers to the BlackPart (where you drag the GreyPart on) in my game. It needs to be changed to the BlackPart in your game! How? Follow the steps.
local BlackPart = game.Workspace.Conveyorthing
  1. Open the Workspace
  2. Click on the BlackPart in your game.
  3. Look at the Workspace, the blue marked part is your BlackPart.
  4. What is the blue marked part named? If the name is ‘Part’ change it to a unique name, it can be anything, like ‘conveyor’.
  5. Change line 4, by doing the following:
local BlackPart = game.Workspace.NameOfYourPart
  1. Change ‘NameOfYourPart’ into the name of your part.

  2. the BlackPart in your game can also be inside of a Model. If that is the case, change line 4 .

local BlackPart = game.Workspace.NameOfTheModel.NameOfYourPart

If it still does not work, let me know!

The thing is, if you’d play Cook Burgers on ROBLOX, you’ll see that you can drag the money to the cash deposit and you’ll get the cash. Why name after the owner if that wouldn’t be the case?

1 Like

You are using the part so it should be hit.Name, it’s not a part in a model. Remove the .Parent

I read this message and I thought you wanted the script to work like this. Of course, there are other ways to detect the player. I used this method, as I read the quote above; but it is no problem to use a different method to detect the player. Feel free to change that!

If its a localscript doing the dragging, the server shouldn’t see the part move? Which is probably why you’ve been getting no errors with the scripts other people made for you.
Correct me if I am wrong

1 Like

Correct. The script can’t get the player that is dragging the part, because it is on the server.

This is why @AC_Starmarine came with a solution to name the part to the owner in the dragging script, so the server can see who the owner is of the part, and reward the correct player. Very smart, this way the correct player will be rewarded!

Quote:

So if that happens, my script will do the rest of the work; and the problem is solved. I tested the script in my own game and it works.

But I misunderstood @NoobiDerpieDev, because he wanted to get the player with a different method. My fault, sorry.

So that’s the story, basically.

1 Like

Set the network ownership of the part to the player…
Would that make it so the player moves it on the server too?

1 Like

Network Ownership is also a good way to make a player owner of a Part. In the ServerScript, you will need to check the Network Ownership of the Part, and then you can reward the player too.

So instead of renaming a part to the owner, this can be used too.

Disclaimer: I’m not a very good scripter, so I might be wrong.