Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Not member of model? [closed]

Asked by 9 years ago

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

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 User#5423 17 — 9y
0
Thanks! But the tool is in the backpack? :) jjwood1600 215 — 9y
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. User#5423 17 — 9y

Locked by Goulstem and Redbullusa

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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

0
Thanks, but I checked in the explorer and the tool was in the players backpack though? :( jjwood1600 215 — 9y
0
Yes, when it's unequipped it's in your backpack. But once you equip it then it gets parented to your character(: Goulstem 8144 — 9y
Ad