|
| 24 Jan 2013 03:51 PM |
I've been working on a script builder for the past day or so and I've found a problem; normal scripts execute just fine and dandy, but LocalScripts appear to not run and without any errors in the output.
Here is the code inside both normal scripts and localscripts:
local Script = loadstring(script.SourceValue.Value) Script()
Here is the code of the SB itself:
game.Players.PlayerAdded:connect(function(Player) local Scripts = {} Player.Chatted:connect(function(Message) local MessageLower = string.lower(Message) -- string lowered version of message if string.sub(MessageLower,1,2) == "s/" then -- script local Text = string.sub(Message,3) local NewScript = script.Script:Clone() local TextValue = Instance.new("StringValue",NewScript) TextValue.Name = "SourceValue" TextValue.Value = Text NewScript.Disabled = false NewScript.Parent = game.Workspace NewScript.Name = Player.Name.."'s Script" table.insert(Scripts, 1,NewScript) end if string.sub(MessageLower,1,2) == "l/" then -- localscript local Text = string.sub(Message,3) local NewScript = script.LocalScript:Clone() local TextValue = Instance.new("StringValue",NewScript) TextValue.Name = "SourceValue" TextValue.Value = Text NewScript.Disabled = false NewScript.Parent = Player.Character -- local place NewScript.Name = Player.Name.."'s Script" table.insert(Scripts, 1,NewScript) end if MessageLower == "clear" then for i = 1, #Scripts do local Removee = Scripts[i] Removee.Disabled = true Removee:Remove() end end end) end)
Why is this so? |
|
|
| Report Abuse |
|
|
jrf2112
|
  |
| Joined: 29 Jun 2008 |
| Total Posts: 3354 |
|
|
| 24 Jan 2013 04:27 PM |
| You can't spawn a localscript. You can emulate scripts, but you can't change the source of programs. |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2013 04:34 PM |
@Jr What? I'm not changing the source at all here, merely using loadstring. |
|
|
| Report Abuse |
|
|
jrf2112
|
  |
| Joined: 29 Jun 2008 |
| Total Posts: 3354 |
|
|
| 24 Jan 2013 04:38 PM |
You asked why is this so. I answered.
Loadstring doesn't work like that, then. |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2013 06:55 PM |
| Darn. How do other Script Builders handle local scripts then? |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2013 06:56 PM |
| Ignore him, that is exactly how Loadstring works. I think the problem is an obscere bug with LocalScripts: If you clone a Localscript that already ran, the clone will never run (or something along those lines). Try Cloning the clone of a localscript in Lighting. |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2013 06:58 PM |
And the adventure continues!
( The 'Base' scripts as you will are disabled, but I will however try this in lighting with clones of clones! ) |
|
|
| Report Abuse |
|
|
|
| 24 Jan 2013 07:07 PM |
Tried your edits to my code, didn't work anyhow. LocalScripts still won't launch, but normal scripts work just dandy. ( Test Trial was one normal script, 1 local scripts and then 1 normal scripts. Both normal scripts functioned just fine, but the localscript didn't fire, and had no error. )
game.Players.PlayerAdded:connect(function(Player) local Scripts = {} Player.Chatted:connect(function(Message) local MessageLower = string.lower(Message) -- string lowered version of message if string.sub(MessageLower,1,2) == "s/" then -- script local Text = string.sub(Message,3) local NewScript = game.Lighting.Script:Clone() local TextValue = Instance.new("StringValue",NewScript) TextValue.Name = "SourceValue" TextValue.Value = Text NewScript.Disabled = false NewScript.Parent = game.Workspace NewScript.Name = Player.Name.."'s Script" table.insert(Scripts, 1,NewScript) end if string.sub(MessageLower,1,2) == "l/" then -- localscript local Text = string.sub(Message,3) local OldScript = game.Lighting.LocalScript:Clone() -- test stuff OldScript.Disabled = true local NewScript = OldScript:Clone() NewScript.Disabled = true local TextValue = Instance.new("StringValue",NewScript) TextValue.Name = "SourceValue" TextValue.Value = Text NewScript.Parent = Player.Character -- local place NewScript.Disabled = false NewScript.Name = Player.Name.."'s Script" table.insert(Scripts, 1,NewScript) end if MessageLower == "clear" then for i = 1, #Scripts do local Removee = Scripts[i] Removee.Disabled = true Removee:Remove() end end end) end) |
|
|
| Report Abuse |
|
|