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: Odd script error

Previous Thread :: Next Thread 
ExosXguy is not online. ExosXguy
Joined: 10 Oct 2010
Total Posts: 2239
21 Jun 2013 02:08 PM
Can't seem to get my head around it. It worked changing a torso's transparency, but not for cloning GUI's into the player's PlayerGui.


while true do
local p = game.Players:GetChildren()
for i=1,#p do
if ((p[i].Character.Torso.Position - script.Parent.Position).magnitude < script.Parent.Size.magnitude*2) then
a = script.Lift2:Clone() -- Around here it starts to mess up, output pasted below
a.Parent = p[i].PlayerGui
elseif ((p[i].Character.Torso.Position - script.Parent.Position).magnitude > script.Parent.Size.magnitude*2) then
a:Remove()
end
end
wait()
end

Output:


20:01:22.200 - Workspace.Lf2.Teleport:8: attempt to index global 'a' (a nil value)
Report Abuse
sbk28 is not online. sbk28
Joined: 15 Nov 2008
Total Posts: 2528
21 Jun 2013 02:12 PM
"Remove()"

:remove()

or

:Destroy()

try that

not sure if that's your error though
Report Abuse
Unsubstantial is not online. Unsubstantial
Joined: 11 Sep 2012
Total Posts: 872
21 Jun 2013 02:13 PM
@sbk off you hop
Report Abuse
sbk28 is not online. sbk28
Joined: 15 Nov 2008
Total Posts: 2528
21 Jun 2013 02:14 PM
Why do I get the feeling you can do

":Remove()"

now

ugh, I never pay attention to this. I always use :Destroy()

but if you're going to tell me to hop off at least give him an answer
Report Abuse
ExosXguy is not online. ExosXguy
Joined: 10 Oct 2010
Total Posts: 2239
21 Jun 2013 02:15 PM
Unsubstantial is on steam with me @Sbk

And no worries, I found the error myself, the elseif statement didn't know what 'a' was, so I made some fixes.
Report Abuse
sbk28 is not online. sbk28
Joined: 15 Nov 2008
Total Posts: 2528
21 Jun 2013 02:16 PM
after checking


You only make A if something happens

but you delete it in elseif
Report Abuse
Unsubstantial is not online. Unsubstantial
Joined: 11 Sep 2012
Total Posts: 872
21 Jun 2013 02:16 PM
ok - here:
It's either trying to remove something which is nil, meaning you should add somewhere in the if statement "and a~=nil"
else - it's probably because "a" wasn't defined, since it skipped to the elseif statement.
Report Abuse
sbk28 is not online. sbk28
Joined: 15 Nov 2008
Total Posts: 2528
21 Jun 2013 02:16 PM
okay nvm then

I feel kind of stupid now.

I apologize for that issue before, I only ever use ":Destroy()" or "Debris.AddItem()"
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