gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 18 Jul 2011 10:10 PM |
| how can you name the Parent of a GUI, when the GUI is in the StarterGUI? i mean, how can you define the humanoid who is dojg something, using a script is in the starterGUI? i want to make it to where when you click on a GUI, a door opens, when you are a certain distance away or closer. |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 18 Jul 2011 10:14 PM |
| i know that's confusing, so i'll make it simpler, how can you make sure that YOU are the humanoid who is close to a door, from a script in starterGUI? |
|
|
| Report Abuse |
|
|
LPGhatguy
|
  |
 |
| Joined: 27 Jun 2008 |
| Total Posts: 4725 |
|
|
| 18 Jul 2011 10:55 PM |
Your character would be
script.Parent.Parent.Character
Or, if you're using a LocalScript:
game.Players.LocalPlayer.Character
By the way, StarterGui is the same as StarterPack, players don't have a StarterGui in them -- they have a PlayerGui in them, just like players don't have a StarterPack in them, they have a Backpack. |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
| |
|
salem9
|
  |
| Joined: 25 Oct 2008 |
| Total Posts: 23312 |
|
|
| 18 Jul 2011 11:45 PM |
Heirarchy: Game -Players --Player ---PlayerGui ----ScreenGui -----TextButton
script is in TextButton
torso = script.Parent.Parent.Parent.Character.Torso door = workspace.Door distanceAway = 10 -- amount of studs away you can be maximum to open the door
script.Parent.Button1Down:connect(function() if (torso.Position - door.Position).magnitude !distanceAway then door.CanCollide = false door.Transparency = 1 wait(4) door.CanCollide = true door.Transparency = 0 end end)
--note***: replace the ! with a less than symbol, it keeps telling me I'm trying to use HTML |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 18 Jul 2011 11:50 PM |
| though i wasn't really asking for the script, thanks! |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 19 Jul 2011 11:46 AM |
local torso = script.Parent.Parent.Parent.Character.Torso local door = workspace.GUI DoorA local distanceAway = 4
script.Parent.Button1Down:connect(function() function() if (torso.Position - door.Position).magnitude <=distanceAway then script.Parent.BackgroundTransparency = 0 door.CanCollide = false door.Transparency = 1 wait(4) door.CanCollide = true door.Transparency = 0 if (torso.Position - door.Position).magnitude >distanceAway then script.Parent.BackgroundTransparency = 1 end end end) apparently = is expected near distanceAway on line 3 and i can't seem to fix it. |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
| |
|
miz656
|
  |
| Joined: 19 Jul 2010 |
| Total Posts: 15336 |
|
|
| 19 Jul 2011 12:41 PM |
| Well, when you do that what does it say in the output? |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 19 Jul 2011 12:44 PM |
it says what i put on the bottom of that post script:3: = is expected near distanceAway and i can't fix it |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2011 12:45 PM |
On line 2:
local door = workspace["GUI DoorA"] |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 19 Jul 2011 12:48 PM |
| there's nothing wrong with that line though.......... |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2011 12:55 PM |
There is. -.- You have a space in the name.
--Dai Floodcheck-- |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
| |
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 19 Jul 2011 02:04 PM |
local torso = script.Parent.Parent.Parent.Parent.Character.Torso local door = workspace.GUIDoorA local distanceAway = 4 -- amount of studs away you can be maximum to open the door
script.Parent.MouseButton1Down:connect(D) function D() if (torso.Position - door.Position).magnitude <=distanceAway then script.Parent.BackgroundTransparency = 0 door.CanCollide = false door.Transparency = 1 wait(4) door.CanCollide = true door.Transparency = 0 if (torso.Position - door.Position).magnitude >distanceAway then script.Parent.BackgroundTransparency = 1 end end end at this point, i got it past basic errors, however, now it says i attempt to call a nil value when i click the GUI anywhere. help please. |
|
|
| Report Abuse |
|
|
|
| 19 Jul 2011 02:08 PM |
| Put the connection line below the function? |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
| |
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 19 Jul 2011 04:05 PM |
local torso = script.Parent.Parent.Parent.Parent.Character.Torso local door = workspace.GUIDoorA local distanceAway = 4 -- amount of studs away you can be maximum to open the door
if (torso.Position - door.Position).magnitude >distanceAway then script.Parent.BackgroundTransparency = 1 if (torso.Position - door.Position).magnitude <=distanceAway then script.Parent.BackgroundTransparency = 0 if (torso.Position - door.Position).magnitude <=distanceAway then function D() door.CanCollide = false door.Transparency = 1 wait(4) door.CanCollide = true door.Transparency = 0 end end end end script.Parent.MouseButton1Down:connect(D) it worked until i put the transparency thing before the function, now it says i'm calling a nil value again. |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
| |
|
|
| 19 Jul 2011 07:58 PM |
| What is that transparency part all about? o: |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 21 Jul 2011 11:19 PM |
| making the update GUI appear. that's why i have the name "AboutGUI" and i want it to where when you click a Gui that says Updates, it pulls up the update Gui |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
|
| 21 Jul 2011 11:20 PM |
| god, i get my threads wrong ALL the time, i want it to open the door, and make it transparent, and uncollidable. i dunno if that's a word, i just kinda went with my gut feeling............ |
|
|
| Report Abuse |
|
|
|
| 22 Jul 2011 03:21 AM |
| Why is the function inside the ifs? Also, I think you need elseif... |
|
|
| Report Abuse |
|
|
gtd345
|
  |
| Joined: 25 Aug 2009 |
| Total Posts: 210 |
|
| |
|
|
| 22 Jul 2011 10:13 PM |
| When you declare a function inside an if statement, unless said statement is true, the function will be unexistant, in this case, because you have more than 1 if inside each other and its impossible for them all to be true at the same time (mutually exclusive), said function will be nil, therefore making you connect the event to a nil function and erroring. xP |
|
|
| Report Abuse |
|
|