Can you help me fix this script?

I suggest using a debounce than using the property Visible.

im really suspecting the camera is the prob lel print this again


script.Parent.MouseButton1Click:Connect(function()
    print("Button clicked")
	if script.Parent.Next.Visible == false then
        print("Turning visible")
		script.Parent.Next.Visible = true
	else
        print("Turning invisible")
		workspace.Camera.CameraSubject = game.Players.LocalPlayer.Character
		script.Parent.Next.Visible = false
print("Done")

	end
end)

Thanks ill try this now, ill let you know if “Done” gets printed in the output.

Then the problem is likely with
workspace.Camera.CameraSubject = game.Players.LocalPlayer.Character
Try changing it to
workspace.Camera.CameraSubject =game.Players.LocalPlayer.Character:FindFirstChild("Humanoid")

or Here’s a script using a debounce:

 local debounce = false
 
 script.Parent.MouseButton1Click:Connect(function()
     print("Button clicked")
 	if debounce == false then
         print("Turning visible")
 		script.Parent.Next.Visible = true
 	elseif debounce == true then
         print("Turning invisible")
 		workspace.Camera.CameraSubject = game.Players.LocalPlayer.Character
 		script.Parent.Next.Visible = false
 	end
end)
1 Like

So you are 100% sure that there is not overlapping with open and next? I suspect that the next button is stealing the input.

local Button = script.Parent

Button.MouseButton1Click:Connect(function()
	if not Button.Next.Visible then
		Button.Next.Visible = true
	else
		if Button.Next.Visible then
			workspace.Camera.CameraSubject = game.Players.LocalPlayer.Character
			Button.Next.Visible = false
		end
	end
end)

Thanks ill give this a try now.

Try this:

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Next.Visible == false then
		script.Parent.Next.Visible = true
	else
		if script.Parent.Next.Visible == true then
			workspace.CameraType = Enum.CameraType.Scriptable 
			workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character
			script.Parent.Next.Visible = false
		end
	end
end)
1 Like

WAIT! THAT SCRIPT WON’T WORK. Try this updated one.


script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Next.Visible == false then
		script.Parent.Next.Visible = true
	else
		if script.Parent.Next.Visible == true then
			workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable 
			workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character
			script.Parent.Next.Visible = false
		end
	end
end)

Ill double check now, but im positive there isn’t.

Thanks ill try this one, and ill let you know if it works.

Sadly, this script didn’t work either.

What happen? Did the camera move? Did it error?

I got the output error again “ActivateCameraController did not select a module”.

“ActivateCameraController did not select a module” - Help and Feedback / Scripting Support - DevForum | Roblox

1 Like

Try this:


script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Next.Visible == false then
		script.Parent.Next.Visible = true
	else
		if script.Parent.Next.Visible == true then
			workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable 
			workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
			script.Parent.Next.Visible = false
		end
	end
end)

Thanks ill try this one, and ill let you know if it works.

Instead of using an else and then later using an if, I would use an elseif. Other than that the code looks decent to me, but I am tired and probably just haven’t been able to notice the mistakes yet.

I think this will work, if it does then mark this as a solution.

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Next.Visible == false then
		script.Parent.Next.Visible = true
	elseif script.Parent.Next.Visible == true then
		wait()
		game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
		script.Parent.Next.Visible = false
	end
end)
2 Likes

Yes, this works thanks for that!

1 Like