What you should know is that im trying to create everything in one script
and the shor variant of down below is that im trying to create a script with a script basically but i dont know how to write anything in the script that was created by my first script. Sorry if this is confusing maybe this will help:
`~~~~~~~~~~~~~~~~~
Button = Instance.new ("Part")
Button.BrickColor = BrickColor.new ("White")
Button.Anchored = true
Button.Position = Vector3.new (13.5, 5.5, -9)
Button.Size = Vector3.new (5, 1, 1)
Button.Name = ("Button")
Button.Parent = game.Workspace
ButtonClick = Instance.new ("ClickDetector")
ButtonClick.Parent = game.Workspace.Button
ButtonScript = Instance.new ("Script")
ButtonScript.Parent = game.Workspace.Button
~~~~~~~~~~~~~~~~~ this is the code and as you see i managed to create a script altough i dont know how to make it so there is code in the script because the code has to be in the script when it is created
If you somehow understood me help would be appreciated because i cant find answers on youtube
Hi!
From what I am reading, you want to create a script and put it inside the button, and then add code to it remotely. Sadly, this isn't possible.
What you can do however, manually create a script in Studio, write the code inside, and put it inside ServerScriptService (or anything else you prefer), and then make it so your original script Clones the self-written one, and puts it inside the button.
Example, with your code included:
local ButtonScript= game.ServerScriptService:FindFirstChild("ButtonScript"):Clone() --Gets the script from where you put it Button = Instance.new ("Part") Button.BrickColor = BrickColor.new ("White") Button.Anchored = true Button.Position = Vector3.new (13.5, 5.5, -9) Button.Size = Vector3.new (5, 1, 1) Button.Name = ("Button") Button.Parent = game.Workspace ButtonClick = Instance.new ("ClickDetector") ButtonClick.Parent = game.Workspace.Button ButtonScript.Parent = game.Workspace.Button
Now if you run the code, the script should be inside your button!
EDIT: I changed the Variables to what you made them, and re-ordered the script because I made a small order mistake!