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

How do I move a script to another service once a button is clicked?

Asked by 5 years ago
Edited 5 years ago

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)
0
Where is your problem occurring? Why are you trying to 'move a script to another service once a button is clicked'? pidgey 548 — 5y
0
I am trying to move the camera script to startergui once the play button is clicked. AwesomeMrBird -79 — 5y
0
I do not know where it is occuring. AwesomeMrBird -79 — 5y

1 answer

Log in to vote
0
Answered by
174gb 290 Moderation Voter
5 years ago

-- 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)
Ad

Answer this question