thombot2
|
  |
| Joined: 15 Oct 2008 |
| Total Posts: 104 |
|
|
| 15 Jul 2013 12:34 AM |
| I know part.Parent:FindFirstChild("Humanoid") but is there anyway to find them in Players instead of Workspace. Maybe part.Parent:FindFirstChild("Players") or something. I am trying to make a onTouch script that will insert a gui into who ever touches it. So I want to find the persons local PlayerGui. |
|
|
| Report Abuse |
|
|
|
| 15 Jul 2013 12:39 AM |
--Event stuff, Hit being the part that hit.
local Character = Hit.Parent local Player = Game.Players:GetPlayerFromCharacter(Character) if Player then print(Player.PlayerGui) end |
|
|
| Report Abuse |
|
|
thombot2
|
  |
| Joined: 15 Oct 2008 |
| Total Posts: 104 |
|
|
| 15 Jul 2013 12:46 AM |
So something like this?
local Character = Hit.Parent local Player = Game.Players:GetPlayerFromCharacter(Character) if Player then game.Lighting.gui.Parent = Player.PlayerGui end |
|
|
| Report Abuse |
|
|
| |
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 15 Jul 2013 12:47 AM |
| You'd want to clone it; otherwise it won't be there for the next person |
|
|
| Report Abuse |
|
|
thombot2
|
  |
| Joined: 15 Oct 2008 |
| Total Posts: 104 |
|
| |
|
thombot2
|
  |
| Joined: 15 Oct 2008 |
| Total Posts: 104 |
|
|
| 15 Jul 2013 12:50 AM |
Wait.
local Character = Hit.Parent local Player = Game.Players:GetPlayerFromCharacter(Character) if Player then game.Lighting.Gui:Clone().Parent = Player.PlayerGui end
This didn't work. Why is that? |
|
|
| Report Abuse |
|
|
| |
|
thombot2
|
  |
| Joined: 15 Oct 2008 |
| Total Posts: 104 |
|
|
| 15 Jul 2013 12:51 AM |
| Nope the title of the Gui is spelt with a capital G. I went back and checked. |
|
|
| Report Abuse |
|
|
thombot2
|
  |
| Joined: 15 Oct 2008 |
| Total Posts: 104 |
|
|
| 15 Jul 2013 12:56 AM |
| Did I do something wrong? I have tried multple times. I edited the script a few times too. It doesn't seem to work. |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 15 Jul 2013 01:47 AM |
What's the output?
Scripting Tutorials: youtube.com/user/smiley599roblox |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 15 Jul 2013 01:50 AM |
Also, thombot, when you said, "Maybe part.Parent:FindFirstChild("Players")", you suggested you did not know was the 'part' thing is. If you know what makes a player (eg. Head, Right Leg), copy this into a script, and drag it into a part.
function onTouched(hit) print(hit.Name) -- I am not sure, should be just be print(hit)? end script.Parent.Touched:connect(onTouched)
Ignore the comment for now, go onto test and touch the part. What does it print?
Scripting Tutorials: youtube.com/user/smiley599roblox |
|
|
| Report Abuse |
|
|
smiley599
|
  |
| Joined: 23 Jan 2010 |
| Total Posts: 21869 |
|
|
| 15 Jul 2013 01:50 AM |
Looking back, I really should have used 'part' in the example. Urgh
Scripting Tutorials: youtube.com/user/smiley599roblox |
|
|
| Report Abuse |
|
|
lax0131
|
  |
| Joined: 20 Nov 2008 |
| Total Posts: 132 |
|
| |
|
lax0131
|
  |
| Joined: 20 Nov 2008 |
| Total Posts: 132 |
|
|
| 15 Jul 2013 02:05 AM |
| Glad your on roblox your a great helper |
|
|
| Report Abuse |
|
|
thombot2
|
  |
| Joined: 15 Oct 2008 |
| Total Posts: 104 |
|
|
| 15 Jul 2013 02:14 AM |
| I figured it out with tons of help. May I ask who you are "glad" is on roblox? Also who is a great helper? |
|
|
| Report Abuse |
|
|