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 » Scripters
Home Search
 

Re: How to make a script ignore an error?

Previous Thread :: Next Thread 
davisky2 is not online. davisky2
Joined: 04 Mar 2012
Total Posts: 4710
26 Jul 2015 01:47 PM
For now, if an error is found - script stops working. But i have 2 same scripts - one works normally as expected and other one errors even though it shouldn't. How can i make so the script ignores the error?


~davisky~
Report Abuse
Vyxium is not online. Vyxium
Joined: 31 Aug 2010
Total Posts: 1020
26 Jul 2015 01:47 PM
fix it
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
26 Jul 2015 01:48 PM
You don't want to ignore the error, you want to figure out what is causing it. It's erroring because you're doing something wrong.

But if you don't care about this and you want to have bad habits, use pcall.
Report Abuse
davisky2 is not online. davisky2
Joined: 04 Mar 2012
Total Posts: 4710
26 Jul 2015 01:50 PM
Ok, 2 same scripts:

repeat wait() until script:findFirstChild("Code")
if script.Code.Value ~= "" then
loadstring(script.Code.Value)()
end --Works fine...


repeat wait() until script:findFirstChild("Code")
if script.Code.Value ~= "" then
loadstring(script.Code.Value)()-- Errors here
end

Error:
Workspace.Countdown.ScriptBase:3: attempt to call a nil value
21:45:09.488 - Stack Begin
21:45:09.488 - Script 'Workspace.Countdown.ScriptBase', Line 3

Both of them run at the same time.


~davisky~
Report Abuse
Vyxium is not online. Vyxium
Joined: 31 Aug 2010
Total Posts: 1020
26 Jul 2015 01:52 PM
why do you have parameters after parameters
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
26 Jul 2015 01:53 PM
Is the second one in a local script?
Report Abuse
davisky2 is not online. davisky2
Joined: 04 Mar 2012
Total Posts: 4710
26 Jul 2015 01:55 PM
no, both are normal scripts.

(Cntkillme, i just started making a new place, nothing much in there so if you want i can give you a copy of it to investigate)


~davisky~
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
26 Jul 2015 02:33 PM
Clearly it's because the code in .Value has an error. pcall it if you want the script to continue working.

Also sneaky advertising: There's no way to make a script ignore syntax errors, but there's a suggestion for it here: http://www.roblox.com/Forum/ShowPost.aspx?PostID=154954463

Syntax errors, not logical errors :P
Report Abuse
davisky2 is not online. davisky2
Joined: 04 Mar 2012
Total Posts: 4710
27 Jul 2015 03:03 PM
Tell me, what is the error here then?

while true do wait() if script.Parent.Parent.Value == 0 then script.Parent:Destroy() end


~davisky~
Report Abuse
Semaphorism is not online. Semaphorism
Joined: 16 Feb 2008
Total Posts: 4831
27 Jul 2015 03:04 PM
repeat wait() until script:FindFirstChild("Code")
if script.Code.Value ~= "" then
local success, ermsg = pcall(function()
loadstring(script.Code.Value)()-- Errors here
end)
if not success then
print(ermsg)
end
end


Try this instead.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
27 Jul 2015 03:05 PM
You are missing an end
Report Abuse
davisky2 is not online. davisky2
Joined: 04 Mar 2012
Total Posts: 4710
27 Jul 2015 03:11 PM
I changed the script a little bit, i managed to remove the error but it doesn't do what it should have. Here is the script:

repeat wait() until script.Parent ~= nil repeat wait() until script.Parent.Value == 0 script.Parent:Destory()

When the value is 0 the thing still stays and keeps decreasing... :/


~davisky~
Report Abuse
davisky2 is not online. davisky2
Joined: 04 Mar 2012
Total Posts: 4710
27 Jul 2015 03:13 PM
Nvm i just had a typo now. Thanks who tried to help me!


~davisky~
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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