Tried making a script that changes your in-game character if you have a certain ID, but i just made the game unplayable

I’m trying to make a script that when you join, if you have a certain ID, your character changes to another one, but i just made the game unplayable…
Here’s the script:

game:GetService("Players").CharacterAutoLoads = false

local function onPlayerAdded(player)
	if player.UserID == 1929382694 then
		player:LoadCharacterWithHumanoidDescription(game.Workspace.SpecialAvatars.HumanoidDescription1)
	else
		game:GetService("Players").CharacterAutoLoads = true
	end
end

game.Players.PlayerAdded:Connect(onPlayerAdded)

When i join, the game loads, but i cant move, zoom-in/out my camera, all i can do is interact with the default UI’s (it looks like when the game is loading but the loading UI didn’t loaded yet)


What’s wrong with the script?

set that cameras subject to the characters humanoid.

example:

camera.CameraSubject = player.Character.Humanoid

I wouldn’t really know if this would work if someone could correct me that’d be great but so far that’s what worked for me when I had this issue.

2 Likes

CharacterAutoLoads is a property that determines if the character will spawn by itself or not.
Since you disabled it for the user having that userID, and reenabled it for others, it won’t spawn that user
CharacterAutoLoads prevents RŌBLOX from spawning a character itself. You must spawn the user using LoadCharacter every time the user has to respawn
However, in your case, you called LoadCharacterWithHumanoidDescription immidiately after player joined. The player is likely not yet fully loaded and not ready to spawn yet. You should wait until the player is ready.
Note that also that user won’t respawn unless you load his character again if he dies, since auto load is disabled

1 Like

Oh! Thanks too, it looks better now. (: