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
 

Help with a Script Builder compiler

Previous Thread :: Next Thread 
Usering is online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
01 Jan 2013 04:42 AM
So I made this cool Gui that updates the text whenever a value gets changed. That works. The following script is a LocalScript inside of a Frame. So when a player chats "script/CODE", and they get an error, it shows up in the gui. But if I say "script/ppppprrrrrinnnnnnnntt(hi))", it doesnt do anything. So basically I want it to catch better errors than what it gets. When you get a syntax error, the script breaks. Any help?
If you would like to see what I mean, you can test it out at my testing place:
http://www.roblox.com/Testing-place?id=100791424

player = game.Players.LocalPlayer

player.Chatted:connect(function(msg)
if string.sub(msg,1,7) == "script/" then
pcall(function()code,error = loadstring(string.sub(msg,8))
if error then --works sometimes
script.Parent.Errors.Value = error --theres a value named 'Errors' in script.Parent
else
code() --loads the code if correct, doesn't always work
end
end)
end
end)
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
01 Jan 2013 04:54 AM
So, make the following code your LocalScript:

local player = game.Players.LocalPlayer
local subscript = script.Script -- Add a script to the LocalScript named Script

player.Chatted:connect(function(message)
if message:sub(1,7):lower() == "script/" then
local s = subscript:Clone()
s.source.Value = message:sub(8)
s.Parent = Workspace
s.Disabled = false
end
end)


Then, create a server script in the LocalScript and name it Script.
Make the script disabled.
Add a StringValue to the script and name it source

Make the script's code the following:

local bool,err = ypcall(loadstring(script.source.Value)) if err then print err end
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
01 Jan 2013 04:59 AM
I forgot parentheses on the print in the script code.
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
01 Jan 2013 06:27 AM
Pcall returns a bool (false if no error, true if error) and an error message. You have to change that.
Report Abuse
Usering is online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
01 Jan 2013 12:23 PM
@Iam, I don't want to do that. I want it to load the string inside of the script so it can catch errors and report them locally. If it's a server side script that gets cloned into workspace, it can't report errors to the LocalPlayer.
Report Abuse
Usering is online. Usering
Joined: 18 Aug 2012
Total Posts: 10281
01 Jan 2013 12:43 PM
I combined Awesome's script and mine and it works perfectly!
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