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: Something wrong with this script?

Previous Thread :: Next Thread 
badgraphix is not online. badgraphix
Joined: 26 Nov 2007
Total Posts: 22800
09 Apr 2012 05:20 PM
script.Parent.Touched:connect(function()
local bool, err = pcall(function()

print("YEAH TOUCHED")
wait(3)
print("3 SECONDS LATER") end)

end)
if not bool then
print("Error with teleporter.")
end



It prints the first message, but when it tries to print the second message, the output says:
attempt to call a nil value
cannot resume non-suspended coroutine
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Apr 2012 05:27 PM
Bool is local, and you end the function before you call bool.
Report Abuse
badgraphix is not online. badgraphix
Joined: 26 Nov 2007
Total Posts: 22800
09 Apr 2012 05:29 PM
I'm still getting the same error messages.

It should be noted that it works fine when the wait and second print message are gone.
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Apr 2012 05:34 PM
bool = false
script.Parent.Touched:connect(function()
bool = true
print("YEAH TOUCHED")
wait(3)
print("3 SECONDS LATER")
end)

if bool == false then
print("Error with teleporter.")
end

Try that :P
Report Abuse
badgraphix is not online. badgraphix
Joined: 26 Nov 2007
Total Posts: 22800
09 Apr 2012 05:39 PM
Thanks, I've got it working!
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Apr 2012 05:42 PM
You're welcome. :)
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
09 Apr 2012 05:46 PM
Miz he's using pcall, not just a bool.

script.Parent.Touched:connect(function()
running, error = pcall(function()
print("YEAH TOUCHED")
wait(3)
print("3 SECONDS LATER")
end)
if not running then print(script:GetFullName().." > Error > "..error) end
end)
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
09 Apr 2012 05:47 PM
I know, but I didn't like that code for some reason :P
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