How do i completely stop running a local script after it ran 1 tim, even if the player reloads

im making a loading screen thing and i cant figure out how to stop the script from re-running after it already did. please help

2 Likes

move it to starter player scripts or disable it at the end of the script

1 Like

Set the ResetOnSpawn property of the ScreenGui to false.

its not screengui thats failing, its the fact that the camera movement is not stopping, neither is the camera going back to the player

i found the issue, the event im waiting for is firing, but for some reason my script wont detect it…

can anyone help with that?

Try setting the CameraSubject to the character’s humanoid, and set the CameraType to Enum.CameraType.Custom

well i got most of the script working but now the camera does not move back to the player, how do i do that

For clarification, is the script in particular a ServerScript or a LocalScript?

It would be better to use a LocalScript to handle camera movement, as it’ll be client-specific (game.Workspace.CurrentCamera)

If it’s a ServerScript, try moving your code into a ServerScript, and using the CurrentCamera instead of the Camera.

wdym? also its a local script in playergui

Can you provide the code so I can try to find the issue?

local Loading = true

local LoadingFinished = game.ReplicatedStorage:WaitForChild("StopLoadingAnim")

local loadingg = Instance.new("BoolValue")
loadingg.Parent = game.ReplicatedStorage
loadingg.Value = true


local cam = game.Workspace:WaitForChild("Camera")

local player = game:GetService("Players").LocalPlayer

local character = player.Character
--local cam = game.Workspace.CurrentCamera




cam.CameraType = Enum.CameraType.Scriptable

local focal = game.ReplicatedStorage.Focal:Clone()

focal.Parent = game.Workspace

local Focal = game.Workspace:WaitForChild("Focal")

LoadingFinished.Event:Connect(function()
	print("h")
	Loading = false
	loadingg.Value = false

	cam.CameraSubject = character:WaitForChild("Humanoid")
	cam.CameraType = Enum.CameraType.Custom
end)


if loadingg.Value == true then
	while Loading == true do

		cam.CameraType = Enum.CameraType.Scriptable

		local Cal1 = Focal.Position.X + .1
		local Cal2 = Focal.Position.z - .1

		Focal.Position = Vector3.new(Cal1, 135, Cal2)

		--cam.CFrame = Focal.CFrame

		cam.CFrame = CFrame.new(Focal.Position, Focal.Position - Vector3.yAxis)
		task.wait()
	end
end

Try changing cam to game.Workspace:WaitForChild("CurrentCamera") instead of using the normal camera.

just returns “infinite yeild possibe forcurrent cam” and then the script doenst work

Possibly due to CurrentCamera not being an actual instance, I’m not too sure.

If you instead set it to game.Workspace.CurrentCamera (as seen in the commented-out code), it might work.

yah that worked, thanks mans. i greyed that out because it wasnt working before, but ig now it does.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.