Button not working after being clicked

Hello, the name’s Dash.

I made camera manipulation system and the button to make the camera back to the players character isn’t working.

Problem in this video (739.8 KB)

I can’t seem to figure out why it isn’t working.

Here’s the script what I used. I had this in the StarterPlayerScripts.

local part1 = game.Workspace.Part1
local part2 = game.Workspace.Part2
local e = game.Workspace.e
local button = game.StarterGui.ScreenGui:WaitForChild("TextButton") 
local clickDetector = e:WaitForChild("ClickDetector")
local Camera = workspace.CurrentCamera
local plr = game.Players.LocalPlayer

clickDetector.MouseClick:Connect(function()
	Camera.CameraType = "Scriptable"
	Camera:Interpolate(part1.CFrame, part2.CFrame, 2)
end)

button.MouseButton1Click:Connect(function()
	Camera.CameraType = "Custom"
	Camera.CameraSubject = plr.Character.Humanoid
end)

Thanks if you can help!
-Dash

You are referencing the button in ScreenGui, not PlayerGui.

1 Like