"Instance:Destroy()" and "script.Disabled = true" not working?

I have a script that uses camera manipulation to show the map loading whilst a gui screen appears. It has a part in the sky that the CurrentCamera goes to, however when I destroy the script, it still goes after the player resets. I have tried disabling it before destroying it, even then it still won’t work. Here is the script used.

local Player = game.Players.LocalPlayer

local Character = Player.Character or Player.CharacterAdded:Wait()

local Camera = workspace.CurrentCamera

repeat wait()

Camera.CameraType = Enum.CameraType.Scriptable

until Camera.CameraType == Enum.CameraType.Scriptable

Camera.CFrame = workspace.LoadingCam.CFrame

wait(5)

Camera.CameraType = Enum.CameraType.Custom

if Camera.CameraType == Enum.CameraType.Custom then

script.Disabled = true

script:Destroy()

end

Any help i s appreciated.
And yes, I did do research, I haven’t found anyone with the same problem since this uses cameramanipulation.

1 Like

Where is the script located?

Example: workspace, StarterGui, ReplicatedFirst

If the script is somewhere in StarterGui or StarterPlayer.StarterCharacterScripts then a new one would be run every time the player respawns. To make it run only once when the player joins put it in StarterPlayer.StarterPlayerScripts.

StarterGui (random text to get this past min amount of letters)

If a script is located in somewhere like StarterGui, or StarterPlayerScripts, that means the script would re-run everytime you reset, I don’t think I need to explain why. You could parent the script to the Gui, that way once the Gui has disappeared, the script wont activate unless you manually trigger it

So I should create a GUI in startergui and add the script inside and then tell the script to disable the GUI?

You should put your Gui in ReplicatedFirst, and parent the gui to a LocalScript. Have the LocalScript that the Gui is parented to clone the Gui into the players PlayerGui.

Either it didn’t work, or I did something wrong, I made a screengui, named it loadscriptgui, added a localscript inside the gui to parent it to the load script in startergui, then in the original load script, I added “game.ReplicatedFirst.loadscriptgui.Parent = game.Players.LocalPlayer.PlayerGui” right under “if Camera.CameraType == Enum.CameraType.Custom then”

Is this what you meant or is something very off?

undo all of what i just told you to do, and just do this:

In the original Gui you made before the changes I told you to make, select the screengui, and uncheck the box that says “ResetOnSpawn”

Somehow it took me this long to realize what you meant, I have gotten it to work, thank you so much!