Custom Character Auto Dies

So I have this goofy looking dinosaur custom character for a game I am working on. We have a lot of other custom characters there, but none of them have their own rig and animations, we simply weld them to an invisble character inside them, and it looks fine.
dino

We have a gui where you can choose what animal you want to be, which does so by this code in a button for every animal:

Button.MouseButton1Down:Connect(function()
	script.Parent.Enabled = false
	local ChosenCharacter = item:Clone()
	local CurrentCharacter = Player.Character
	local LocalScripts = {}
	
			
	for index2,item2 in pairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
		if item2:IsA("LocalScript") then
			table.insert(LocalScripts,item2:Clone())
		else
			if ChosenCharacter.Name == "Dino" then -- This makes it so that the Dino doesn't get the localscripts, as I thought this was the problem at first
			else
				item2:Clone().Parent = ChosenCharacter
			end
			
		end
	end
			
	CurrentCharacter.Health:Clone().Parent = ChosenCharacter
	table.insert(LocalScripts,CurrentCharacter.Animate:Clone())
	ChosenCharacter.Parent = workspace
	Player.Character = ChosenCharacter
	for index2,item2 in pairs(LocalScripts) do
		if ChosenCharacter.Name == "Dino" then
			local clone = script.Animate:Clone() --Custom animations for the dino
			clone.Parent = ChosenCharacter
			clone.Enabled = true
		else
			item2.Parent = ChosenCharacter
		end
		
	end
	SetSubject:FireClient(Player,ChosenCharacter.Humanoid) --This sets the camera to the new character with another script
	
	local Connection
	
	local function onDied()
		wait(game.Players.RespawnTime)
		Player:LoadCharacter()
		script.Parent.Enabled = true
		if Connection then
			Connection:Disconnect()
		end
	end
	
	Connection = ChosenCharacter.Humanoid.Died:Connect(onDied)
	
end)

But from what I’ve seen, the problem is not here. I’ve tried with other methods and the bug also occurs then. I’ve also looked at the devforum and I found this post with the same problem, but no solution. There was a post there, suggesting to put a forcefield into the custom character, which apparently helped the person with the bug, not sure how, but when I tried it, the forcefield just spawned at origo, not at the character.

So what is the problem? Well, when you spawn in as the character, it works fine for about 4 seconds, then you respawn as your normal character. The Gui is also not shown. Check this video:

(`https://youtu.be/XPKW1pSgabE) for those who block third party cookies

My guess to why this happens is that is has something to do with how the character is built that messes up. The fact that it works completely fine when I put the custom character into starterplayer and name it StarterCharacter suports this theroy. I followed this youtube tutorial to make the custom character. Here’s a screenshot of the components in the character and the rig setup:

All the components of Dino
image View of the rig using Rig Editor plugin by goro7.

Does anyone know ore have any idea why this happens? Help greatly appretiated! :happy1:

1 Like

Try checking if the player is still morphed as a Dino after the respawn, and if not call the function that turns the player into the Dino

Example:

local dino = false

local function morphToDino()
--morph code
end

if dino == false then
  morphToDino()
else
  return
end
1 Like

The problem i am seeing is that that once you reset the weld is gone, what you can do is instead of welding it to the player you can set it as a startercharachter,

If you didnt know already if you put a model named StarterCharachter in StarterCharachterScripts it transforms the character into the model you placed

You could look more on youtube

Is it possible to do even after the game is started? I’ve never tried that way, I thought it would be impossible, especially if I wanted to do it locally

My bad just read out the final lines, you could do a loop that checks if a player died and if it returns true you morhp it again

You can do it via RemoteEvents, Dinasour Simulator is a great example

2 Likes

I tried this, but the problem is that the player doesn’t die, the character just respawns somehow

Perhaps the Humanoid inside the dino might be the problem

Try checking with both, dino health and player health

How do I check player health? What is that?

Every player has a charachter in workspace. That charachter has a humanoid, try checking the humanoid health like you sent in the example and same with the dino

But the Dino and the player’s character is the same as i use Player.Character = Dino

Now you see, that might be the problem, as you cant really check that, can you send the full script that you assign the health of the dino?

You mean CurrentCharacter.Health:Clone().Parent = ChosenCharacter?

Sorry if I missunderstand things, I’m not very sure about all parts of how this script works

No, my question is how did you set the dino health to be the same as a player if not in a script? If there is a script then if you may send it

Can you try adding prints on the onDied function? Before and after the wait?

1 Like

There’s no other script that intersects with the Dino’s health, we put the propreties Humanoid.Maxhealth and Humanoid.Health to 300 manually. So the health does increase when you become the Dino.

I added

local function onDied()
	print("OnDied before wait")
	wait(game.Players.RespawnTime)
	print("OnDied after wait")
	Player:LoadCharacter()
	print("OnDied after :LoadCharacter")
	script.Parent.Enabled = true
	if Connection then
		Connection:Disconnect()
	end
end

Gives all three when I reset before the character respawns, but none if I wait until the bug occurs