Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Not member of model?

Hi guys! I have a tool which is in the backpack. In the script in the tool, I try to change a value which is in the player but for some reason I get the error that "Products is not a valid member of Model"?! This is the hierarchy.

Player / (in the player are these...)

Backpack -Tool -Script in tool that changes the value

Products

  • Value I am trying to change called Cash

I am using this script.

script.Parent.Parent.Products.Cash.Value = 0

Any ideas? Thanks

3 comments

0

When equipped tools go to the workspace so the parent is not the game player but the model of the player, all you need to do is go through game.players.[player name].Cash.Value to change the value

0

Thanks! But the tool is in the backpack? :)

0

The parent of the tool is changed when the player equipts the tool, you can see this happerning when you test the roblox project in solo mode.

1 answer

✓ Accepted answer

Your problem is that when you actually equip a tool it's parent becomes your character, rather than your player's backpack.


So to fix? Use a localscript in your tool and define the player as game.Players.LocalPlayer.


Example;

local plr = game.Players.LocalPlayer
plr.Products.Cash.Value = 0

NOTE: Check to make sure you're indexing the correct areas! In a normal leaderboard setup then the hierarchy is;

Player

~ leaderstats

~ ~ Money

2 comments

0

Thanks, but I checked in the explorer and the tool was in the players backpack though? :(

0

Yes, when it's unequipped it's in your backpack. But once you equip it then it gets parented to your character(:

This discussion is preserved as it was. New answers, comments, and votes are closed.