Nothing runs after LoadCharacter()

I want the function to fire an event and respawn the player but nothing runs under LoadCharacter. are there any better alternatives to respawn character or am I doing something wrong?

BotanicalEntitySpawner.OnServerEvent:Connect(function(plr: Player, targetPlayer: Player, reason: string, _time: number)
	if plr then
		BerserkEvent:FireClient(plr, reason, _time)
		plr:LoadCharacter()
		print("helloo you are print?")
	end
end)

It works when the character is R6 but I need it to run on R15 characters

1 Like

Try putting the print before loading the character, to see if it has something to do with plr being nil or yield on BerserkEvent, using prints to debug is also a good idea.
Also, is it a local script? If so, is it in StarterCharacterScripts?

No, it’s a script

I don’t know what causes it not to print but It is fixed when the game is R6.
Is there some kind of yield on LoadCharacter when the character is R15 that I don’t know of?
Anyways my problem is yet not solved since I’m trying to work with R15 Characters

1 Like

Do you have CharacterAutoLoads to false? Also loading the character will destroy the script, because that’s a script in the character, so it will stop running.

1 Like

Maybe theres a yield on BerserkEvent that causes it to stop cuz it is waiting for a part on the character which only exists on R6, also what does BerserkEvent do exactly?

I can leave LoadCharacter blank and it will load the character yet it wont run any code after

BotanicalEntitySpawner.OnServerEvent:Connect(function(plr: Player)
	plr:LoadCharacter()
	print("Character loaded")
end)
1 Like

Hm… Does it actually load the character? If not, it may be a yield on whatever script is firing the RemoteEvent, if it is loading the character, then I have no idea why it isn’t working. Im gonna open studio to try and see if it works, it may take a while cuz my laptop is busted

Did you read this? Is your script in StarterCharacterScripts?

4 Likes

He said it was a script, and even if the localscript who fired the event got destroyed, it should still print. And I tried it on studio rn, and it works perfectly fine

I’m asking where it is, not what it is. Is it in StarterCharacterScripts?

1 Like

Oh yea, you’re right, I putted it in the StarterCharacterScripts and it didn’t printed, its probably that

Apologies I missed that. Moved the script off somewhere ensuring it wouldn’t be in character (was inside a Tool before) and it works. Much appreciated man!

2 Likes

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