Script not running / printing after task.wait()

The code lines:

		print(Player.Name.. ' won!')
		
		task.wait(4)
		
		print(Arena.Prompt.ProximityPrompt.Enabled, Arena.Prompt.ProximityPrompt)
		Arena.Prompt.ProximityPrompt.Enabled = true

		task.spawn(function() Player:LoadCharacter() end)
		task.spawn(function() Opponent:LoadCharacter() end)

Prints just the first line, and the second one is just forgotten and not printing even after 4 seconds.

Could you send me the entire script?

By any chance, is this wrapped in a pcall

Yeah, it comes from a module script and i’ll also provide the script that runs it:

ArenaModule.ResetArena = function(Player, Opponent)
	print("Game ended.")
	local Arena = Player.CurrentArena.Value
	if Arena ~= nil then
		Events.ArenaEvents.FightEnded:FireClient(Player)
		Events.ArenaEvents.FightEnded:FireClient(Opponent)
		
		Arena.OpponentA.Value = nil
		Arena.OpponentB.Value = nil

		Player.CurrentArena.Value = nil
		Opponent.CurrentArena.Value = nil
		
		print(Player.Name.. ' won!')
		
		task.wait(4)
		
		print(Arena.Prompt.ProximityPrompt.Enabled, Arena.Prompt.ProximityPrompt)
		Arena.Prompt.ProximityPrompt.Enabled = true
		
		task.spawn(function() Player:LoadCharacter() end)
		task.spawn(function() Opponent:LoadCharacter() end)
	end
end

the script is just:

ArenaModule.ResetArena(Player, Arena.OpponentB.Value)

What happens when you remove task.wait()?

It works, I just tried it and placed all the things that come after, before the task.wait, and it runs…

Could you send the script that executes that function?

Here you go, it’s inside the Character, and listens to their .Died, I would suppose it doesn’t run because 4 seconds elapse since the character died, but is the character dying really stopping a modulescript from running?

Humanoid.Died:Connect(function()
	local Arena = Player.CurrentArena.Value
	if Arena ~= nil then
		ArenaModule.ResetArena(Player, Arena.OpponentB.Value)
		Player.CurrentArena.Value = nil
	end
end)

I’ll try to change the task.wait to something shorter like 1 second and see…

Changing the task.wait to one second instead of 4 seems to work, I guess the modulescript stops running even when the player has died. But instead of putting it to 1 second, i’ll just place the script outside character.

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