Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How do i edit a LocalScript's content form an Instance?

Asked by 5 years ago

So i was making a special GUI for my character and i wanted to insert a script on it, the thing is: Can i edit a LocalScript's content with a script?

The Script:

script.Parent.ChildAdded:Connect(function()
    do
        --Gui
        Instance.new("ScreenGui")
        Instance.Name = "Hi"
        Instance.Parent = game.Players.RedLecko434.PlayerGui
        --Button
        Instance.new("TextButton")
        Instance.Parent = game.Players.RedLecko434.PlayerGui.Hi
        Instance.Name = "ButtonTxSg"
        Instance.Position = {0.905, 0},{0.801, 0}
        --Script
        Instance.new("LocalScript")
        Instance.Parent = game.Players.RedLecko434.PlayerGui.Hi.ButtonTxSg
    end
end)

Also if it isnt possible, could something like this work?

script.Parent.ChildAdded:Connect(function()
    do
        game.ServerStorage.SampleScirpt:GetChildren("RedLecko434")
    end
end

Good luck.

0
wtf User#24403 69 — 5y
0
? Ziffixture 6913 — 5y
0
? RedLecko434 -1 — 5y
0
No, you cannot edit a script's source at all with another script. Btw, you should define the obj with a variable; it's not changing the `Name` or `Parent`, you're doing `Create ScreenGui, now try and index `Name` to `Instance`, and finally try and index `Parent` to `Instance`.` TheeDeathCaster 2368 — 5y
View all comments (2 more)
0
Thanks for the help. RedLecko434 -1 — 5y

1 answer

Log in to vote
0
Answered by
xJigoku 17
5 years ago
Edited 5 years ago

You cannot edit a Local Script from another script. Also as TheeDeathCaster said, you will want to set the instance as a variable, like this...

local Screen = Instance.new("ScreenGui")
Screen.Name = "Hi"
Screen.Parent = game.Players.RedLecko434.PlayerGui

And the error with the second script is that you don't need to add a function, you also would want to set it as a variable. It should look like this...

script.Parent.ChildAdded:Connect(function()
    local children = game.ServerStorage.SampleScirpt:GetChildren()
end

Hope that helped.

0
API Services rejected request with error. HTTP 0 (HTTP 403) RedLecko434 -1 — 5y
0
dude GetChildren() has no argument to pass, why are you using it that way DeceptiveCaster 3761 — 5y
0
my bad, I forgot to remove that, I copied and pasted from his code obv xJigoku 17 — 5y
Ad

Answer this question