|
| 16 Jan 2014 12:26 PM |
I have created a tool that when it hits a part will display a gui but i want to know how to place the gui within PlayerGui from the model of the player?
gui.Parent = script.Parent.Parent.PlayerGui - Something like this.. |
|
|
| Report Abuse |
|
|
|
| 16 Jan 2014 12:26 PM |
| - Links to some kind of forum that teaches this part would be great, thanks. |
|
|
| Report Abuse |
|
|
Kingmouli
|
  |
| Joined: 28 Sep 2012 |
| Total Posts: 1292 |
|
|
| 16 Jan 2014 12:30 PM |
script.Parent.Equipped:connect(function() char = script.Parent.Parent -- the player plyr = game.Players:GetPlayerFromCharacter(char) -- find the plyr corresponding to the char --code end)
To access the PlayerGui you would use plyr.PlayerGui |
|
|
| Report Abuse |
|
|
|
| 16 Jan 2014 12:31 PM |
If you are Parenting the GUI to the Player holding the Tool, I would recommend moving your Script over to a LocalScript. With a LocalScript, you can use this:
gui.Parent = game.Players.LocalPlayer.PlayerGui
LocalPlayer is the Player that the LocalScript belongs to, and is being run by. In other words, if the Player is holding a Tool with a LocalScript that uses LocalPlayer, the LocalPlayer will be the Player holding the Tool.
If you cannot do this, then I think it's time for a lesson in the game hierarchy. The Parent refers to the Instance that another Instance resides in. For example, game.Workspace.Part.Parent is Workspace. Understanding that, you also need to know that the Tool is stored within the Character (not the Backpack) when it is open. Therefore, if the Script is directly inside of the Tool, you can do this:
local player = game.Players:GetPlayerFromCharacter(script.Parent.Parent) -- script.Parent will be the Tool, and script.Parent.Parent will be the Character gui.Parent = player.PlayerGui
Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson |
|
|
| Report Abuse |
|
|
Kingmouli
|
  |
| Joined: 28 Sep 2012 |
| Total Posts: 1292 |
|
|
| 16 Jan 2014 12:32 PM |
| Oh you mean when you touch the part with the tool? You should use the GetPlayerFromCharacter method as used above. |
|
|
| Report Abuse |
|
|
|
| 16 Jan 2014 12:33 PM |
@Kingmouli I wasn't completely sure on what he meant, so I just tried to educate him on the whole topic ;)
Wiki Profile: http://wiki.roblox.com/index.php/User:Nelson |
|
|
| Report Abuse |
|
|