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 move a script to another service once a button is clicked?

Can someone tell me how to fix this script or give me the right code?

function run()
local plr = game.Players.LocalPlayer
local camera = game.Workspace.Camera2:Clone()

if plr.PlayerGui then
camera.Parent = plr.PlayerGui
end
game.ScreenGui.Intro.Play.MouseButton1Click:Connect(run)

3 comments

0

Where is your problem occurring? Why are you trying to 'move a script to another service once a button is clicked'?

0

I am trying to move the camera script to startergui once the play button is clicked.

0

I do not know where it is occuring.

1 answer

-- INSERT LOCAL SCRIPT INSIDE THE BUTTON --

-- put the code below:

local plr = game.Players.LocalPlayer

script.Parent.MouseButton1Click:connect(function)_
	local camera = game.Workspace.Camera2:Clone()
	if not  plr.PlayerGui:FindFirstChild("Camera2") then
	camera.Parent = plr.PlayerGui
	end
end)

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