generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: URGENT SCRIPT HELP!

Previous Thread :: Next Thread 
teufulhund is not online. teufulhund
Joined: 01 Feb 2013
Total Posts: 109
24 Mar 2014 09:45 PM
Hello and im trying to make a script. and the script hase a parent, but the scripts parent also has a parent. In the script how do i refer to the script's parent only without using Parent.Parent???
Report Abuse
tery215 is not online. tery215
Joined: 19 Aug 2009
Total Posts: 3879
24 Mar 2014 09:49 PM
using script.Parent
Report Abuse
teufulhund is not online. teufulhund
Joined: 01 Feb 2013
Total Posts: 109
24 Mar 2014 09:50 PM
this is what i have but it also moves the parent of the script?

function GUIClick()
if (Switch == "Open") then
script.Parent.Parent.Position = UDim2.new(0.-4, 0, 0, 0)
script.Parent.Text = "<--"
Switch = "Close"
elseif (Switch == "Close") then
script.Parent.Parent.Position = UDim2.new(0, -4, 0, 0)
script.Parent.Text = "-->"
Switch = "Open"
end
end
Report Abuse
roboslayer10 is not online. roboslayer10
Joined: 08 Aug 2011
Total Posts: 206
24 Mar 2014 09:50 PM
scriptParent = game.Workspace:FindFirstChild(script.Parent.Name,true)

FindFirstChild() now has two arguments, finding the name, and going through all the children of workspace and going into their children etc. until it finds the name. Only downside is, make sure that the name of the scriptParent is different from everything else.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
24 Mar 2014 09:51 PM
FindFirstChild always had 2 arguments
Report Abuse
roboslayer10 is not online. roboslayer10
Joined: 08 Aug 2011
Total Posts: 206
24 Mar 2014 09:51 PM
oh. Totally different scenario. Ignore my last post.
Report Abuse
roboslayer10 is not online. roboslayer10
Joined: 08 Aug 2011
Total Posts: 206
24 Mar 2014 09:54 PM
blargh I can't say one thing without someone else posting something new!

Well, I didn't know that :FindFirstChild() not only searched for a name, but also scans the children of it and its children's children etc.

I've been using a function that goes through everything.

function unpack(model)
for i,v in pairs(model:GetChildren()) do
if v:IsA("Part") then
v.CanCollide = false
elseif v:IsA("Model") then
unpack(v)
end
end
end

unpack(workspace)


I KNOW that this skips over scanning parts and terrain and wedges and the camera, but its a short rendition to the original function.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image