Hello ! I am working on a mechanic that allows the player but open and exit this camera perspective repeatedly but the ClickDetector seems to only work once.
I believe I read that it is because the Gui is still considered open and therefore scripts that follow the opening of the Gui do not work (?)
Here is the setup (in workspace)
Scripts
OpenGui:
gui = script.Parent.ISpyExitGui
function onClick(click)
gui:Clone()
gui.Parent = click.PlayerGui
end
script.Parent.ClickDetector.MouseClick:connect(onClick)
EXIT:
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
Camera.CameraType = "Scriptable"
Camera.CFrame = game.Workspace.CameraISpy.CFrame
ReturnCamera:
local Camera = game.Workspace.CurrentCamera
script.Parent.MouseButton1Click:Connect(function()
Camera.CameraType = "Custom"
script.Parent.Visible = false
end)
I am in no way a scripter, this is a Frankenstein of different scripts that I was able to edit to eventually work.
I feel the solution to this is simple but I do not have the grasp on scripting that would be required to fix it.
If any additional information is needed let me know
Thanks for any help !
Editing ReturnCamera does not seem to have done anything on its own, and the OpenGui change (both separate and along with the Return Camera edit) breaks the ClickDetector
put the ispyexistgui into startergui and put the opengui script inside the exit button then disable it from the properties. change the open gui script to
local gui = script.Parent
local Camera = game.Workspace.CurrentCamera
function onClick(click)
gui.Parent.Enabled = true
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = (put the part then CFrame)
end
(part).ClickDetector.MouseClick:Connect(onClick)
I dont think you would need exit just disable it for now.
also keep the chanhe of script.Parent.Visible = false to script.Parent.Parent.Enabled = false