Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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.

6 comments

0

wtf

0

?

0

?

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 NametoInstance, and finally try and index ParenttoInstance.

0

Thanks for the help.

1 answer

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.

3 comments

0

API Services rejected request with error. HTTP 0 (HTTP 403)

0

dude GetChildren() has no argument to pass, why are you using it that way

0

my bad, I forgot to remove that, I copied and pasted from his code obv

This discussion is preserved as it was. New answers, comments, and votes are closed.