Character getting stuck in ground

Hello! Currently in the most recent version of Bloxy Kart, there is a major bug where characters will get stuck in the ground after dying.

I have noticed this in the previous version, but only when you change your character, and I thought it was nothing major and just a one time thing.

Since the character system kills you when you get a new character, the reproduction steps are to die some way, most likely being the Obby that was added in this release.

Here is a video of the bug:

If anyone can tell me how I can detect this, I think the easiest solution for now is to detect, kill, repeat until not stuck. I just need help with the detecting part.

Or maybe there is a flaw with the character script.
local StarterCharacterScripts = game.StarterPlayer.StarterCharacterScripts
local PlayerNametag = script.PlayerNametag
local MarketplaceService = game:GetService("MarketplaceService")
local RunService = game:GetService("RunService")

local ChangeCamSubject = game:GetService("ReplicatedStorage").Remotes.ChangeCamSubject

local DataStore2 = require(game:GetService("ServerScriptService").DataStore2)
local TheDatastore = DataStore2.Combine("Characters", "CharactersBackup")


--local datastore = game:GetService("DataStoreService"):GetDataStore("Characters")

local function LoadData(Player)
	local datastore = DataStore2("Characters", Player)
	local id = Player.UserId
	local data

	local success,output = pcall(function()
		data = datastore:GetTable({
			Characters = {""},
			EquippedCharacter = "",
			leaderstats = {{Points = 50}}
		}) 
	end)

	if not success then
		error(output)
	end

	if not data then
		data = {
			Characters = {"Jake"},
			EquippedCharacter = "Jake",
			leaderstats = {50}
		}
	end	

	if not data.leaderstats then data.leaderstats = {} end

	for _,v in pairs(data.Characters) do
		local value = Instance.new("BinaryStringValue")
		value.Parent = Player.Characters
		value.Name = v
	end

	for _,v in pairs(Player.leaderstats:GetChildren()) do
		if data.leaderstats[v.Name] then
			v.Value = data.leaderstats[v.Name]
		end
	end

	--Player.leaderstats.Points.Value = data.leaderstats

	Player:SetAttribute("EquippedCharacter", data.EquippedCharacter)
end

local saveData = function(Player)
	local datastore = DataStore2("Characters", Player)
	local id = Player.UserId
	local data = {
		Characters = {},
		EquippedCharacter = "",
		leaderstats = {}
	}

	for _,v in pairs(Player.Characters:GetChildren()) do
		table.insert(data.Characters,v.Name)
	end

	for _,v in pairs(Player.leaderstats:GetChildren()) do
		data.leaderstats[v.Name] = v.Value
	end	

	data.EquippedCharacter = Player:GetAttribute("EquippedCharacter")

	local success, output = pcall(function()
		datastore:Set(data)
	end)

	if not success then
		error(output)
	end
end

local function AddNametag(Player, Character)
	local Nametag = PlayerNametag:Clone()
	Nametag.PlayerName.Text = Player.DisplayName

	if Player:GetRankInGroup(5123445) == 255 then
		Nametag.Gamepass.Text = "Owner"
	elseif Player:GetRankInGroup(5123445) == 254 then
		Nametag.Gamepass.Text = "Developer"
	elseif Player:GetRankInGroup(5123445) == 252 then
		Nametag.Gamepass.Text = "Contributor"
	elseif MarketplaceService:UserOwnsGamePassAsync(Player.UserId, 13760521) then
		Nametag.Gamepass.Text = "VIP"
		Nametag.PlayerName.RainbowColors.Disabled = false
	elseif Player:GetRankInGroup(5123445) == 201 then
		Nametag.Gamepass.Text = "Moderator"
	elseif MarketplaceService:PlayerOwnsAsset(Player, 6132540172) then
		Nametag.Gamepass.Text = "Beta Tester"
	elseif Player:GetRankInGroup(5123445) == 1 then
		Nametag.Gamepass.Text = "Gamer"
	end

	local Levels = Player:WaitForChild("Levels")

	Nametag.Level.Text = "Level ".. Levels:GetAttribute("Level")
	Levels.AttributeChanged:Connect(function()
		Nametag.Level.Text = "Level ".. Levels:GetAttribute("Level")
	end)

	Nametag.Adornee = Character:WaitForChild("Head")
	Nametag.Parent = Character.Head
end

local function ChangeChar(Player, CharacterModel)
	saveData(Player)
	Player:LoadCharacter()
	local CurrentCharacter = Player.Character
	local pos = CurrentCharacter.PrimaryPart.CFrame

	local animate = CharacterModel:FindFirstChild("Animate")
	local health = CharacterModel:FindFirstChild("Health")

	local curAnimate = CurrentCharacter:FindFirstChild("Animate")
	local curHealth = CurrentCharacter:FindFirstChild("Health")

	if not health and curHealth then
		curHealth:Clone().Parent = CharacterModel
		curHealth:Destroy()
	end 

	CharacterModel.Name = Player.Name
	CharacterModel.Parent = game:GetService("Workspace")
	Player.Character = CharacterModel
	CharacterModel.PrimaryPart:SetNetworkOwner(Player)
	CharacterModel:PivotTo(pos)

	if not animate and curAnimate then
		curAnimate:Clone().Parent = CharacterModel
		curAnimate:Destroy()
	end

	if not CharacterModel.Humanoid:FindFirstChildOfClass("Animator") then
		local Animator = Instance.new("Animator")
		Animator.Parent = CharacterModel.Humanoid
	end

	CurrentCharacter:Destroy()

	for _,v in pairs(StarterCharacterScripts:GetChildren()) do
		if not CharacterModel:FindFirstChild(v.Name) then
			v:Clone().Parent = CharacterModel
		end
	end

	ChangeCamSubject:FireClient(Player, CharacterModel.Humanoid)

	AddNametag(Player, CharacterModel)

	CharacterModel.Humanoid.Died:Connect(function()
		task.wait(game:GetService("Players").RespawnTime)
		updateChar(Player)
	end)
end

function updateChar(Player)
	local equippedChar = Player:GetAttribute("EquippedCharacter")
	local chars = Player.Characters
	local curChar = Player.Character or Player.CharacterAdded:Wait()
	local changing = Player.ChangingChar

	if changing.Value then
		repeat task.wait(0.1) until not changing.Value
	end

	changing.Value = true

	if chars:FindFirstChild(equippedChar) then
		local module = game:GetService("ServerStorage").Characters:FindFirstChild(equippedChar)
		if module then
			local char = module:FindFirstChildOfClass("Model")
			ChangeChar(Player,char:Clone())
		else
			Player:LoadCharacter()
		end
	else
		Player:LoadCharacter()
	end

	task.wait(0.1)
	changing.Value = false
end

local function PlayerAdded(Player)

	-- // This is where we stored Player money.
	local stats = Instance.new("Folder")
	stats.Name = "leaderstats"
	stats.Parent = Player

	-- // This is where we store the purchased character.
	local characterfolder = Instance.new("Folder")
	characterfolder.Parent = Player
	characterfolder.Name = "Characters"

	-- // Player's currency for the character shop.
	local money = Instance.new("IntValue")
	money.Parent = stats
	money.Name = "Points"

	-- // Equipped Character Value
	--local EquippedCharacter = new("StringValue")
	--EquippedCharacter.Parent = Player
	--EquippedCharacter.Name = "EquippedCharacter"

	local changing = Instance.new("BoolValue")
	changing.Parent = Player
	changing.Name = "ChangingChar"

	LoadData(Player)

	updateChar(Player)
	Player:GetAttributeChangedSignal("EquippedCharacter"):Connect(function()
		updateChar(Player)
	end)
end

game:GetService("Players").PlayerAdded:Connect(PlayerAdded)
--game:GetService("Players").PlayerRemoving:Connect(saveData)

Thanks in advance! If you have a possible solution, that will be appreciated.

1 Like

maybe try changing the spawn point higher? this commonly happens in other games like ERLC(When getting teleported).

1 Like

Symptoms of humanoid hip height, perhaps try @InvalidRaycast solution first it has been documented before:

1 Like

Those have already been tried. Should I try pivoting the character a little higher off the ground?

Raise the teleport part several studs off the ground and disable its collisions.

1 Like