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.
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:
View of the rig using Rig Editor plugin by goro7.
Does anyone know ore have any idea why this happens? Help greatly appretiated!