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 |
|
|
|
| 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 |
|
|
|
| 01 Jan 2013 04:59 AM |
| I forgot parentheses on the print in the script code. |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|