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

What should I use to locate the players backpack that clicked buy

This line doesnt work

player = script.Parent.Parent.Parent.Parent.Parent

is there a better way to locate the player who click on a button's backpack?

Plz herlp

2 comments

1

Using a LocalScript you can get player using the LocalPlayer property of the Players service (player = game.Players.LocalPlayer) if you're going to get the player through parents (hierarchy) then do something like this: gui = script.Parent.Parent; player = gui.Parent 

1

ok.. i think i understand now Thanks tho

1 answer

✓ Accepted answer

If it's a LocalScript

player=Game.Players.LocalPlayer

Otherwise, just make sure you've counted the parents properly. The player would be equivalent to StarterGui plus one .Parent.

1 comment

1

thanks

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