Why wont this run properly?

Ill keep this short and simple cause i have no idea what could be causing this.

Why does 11 print but 12 never ever prints? setting the wait to 0 makes 12 print

print(11)
task.wait(1)
print(12) --Any code under here NEVER runs
print(11)
task.wait(0)
print(12) --Any code under here will run

Ofcourse this is not my full code, but i doubt it has anything with the rest of the code to do since everything up to 11 prints

local TweenService = game:GetService("TweenService")

script.TravelTo.Event:Connect(function(Character : Model, Destination : Vector3, Name : string)
	local CurrentCamera = game.Workspace.CurrentCamera
	print(1)
	local DefaultCam = CurrentCamera.CameraType
	print(2)
	CurrentCamera.CameraType = Enum.CameraType.Scriptable
	print(3)
	TweenService:Create(CurrentCamera, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {["CFrame"] = CFrame.lookAt(Character.Head.Position + Vector3.new(0, 50, 0), Character.Head.Position)}):Play()
	print(4)
	task.wait(2)
	print(5)
	TweenService:Create(CurrentCamera, TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {["CFrame"] = CFrame.lookAt(Vector3.new(Character.Head.Position) + Vector3.new(0, 4000, 0), Vector3.new(Character.Head.Position))}):Play()
	print(6)
	TweenService:Create(game.Lighting, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {["ExposureCompensation"] = 5}):Play()
	print(7)
	task.wait(1)
	print(8)
	Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
	print(9)
	CurrentCamera.CFrame = CFrame.lookAt(Character.Head.Position + Vector3.new(10, 4000, 10), Character.Head.Position)
	print(10)
	TweenService:Create(CurrentCamera, TweenInfo.new(4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {["CFrame"] = CFrame.lookAt(Character.Head.Position + Vector3.new(10, 10, 10), Character.Head.Position)}):Play()
	print(11)
	task.wait(1)
	print(12)
	TweenService:Create(game.Lighting, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {["ExposureCompensation"] = 0}):Play()
end)

I also cant set the wait after “print(7)” to more than 1 cause then the same issue occurs

1 Like

while adjusting my wait times it seems like the whole function just shuts down after about 5-6 seconds of running

1 Like

Have you tried printing numbers as a string?

print("12")

the printing isnt the problem. i only added the prints to diagnose the issue. the issue is that nothing after task.wait runs ever

do you destroy the bindable or script anywhere?

No i didnt, altough i seem to have figured out the problem. i tihnk it is cause the character variable gets edited in some way. ill go and try some things to see if i can fix it

1 Like

I think im just gonna rewrite my script cause nothing seems to work

2 Likes

I have managaed to solve it. turns out the function just stops running if the character model gets deleted

1 Like

cause it was parented under a screengui with “ResetOnSpawn” on…

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