Simple task: swap out the current character for a clone of the character on a horse.
What’s happening: the moment I make the switch, the player dies. No loss of health. No triggering of Humanoid.Died. Not even falling over dead, I just see a red flash and reset a few seconds later.
Steps: I have a riderless horse. I clone the player, and rebuild the player on the horse. I set the camera. I add the animate script. All errors squashed. I make the swap and die. I’ve had the same results making the swap on client and server, but server works better.
There’s a second version, where I embrace the death… force it with loadcharacter. I hate this version because there is a split second where the camera goes back to the spawn point. Still completely wrong, but at least I stay on the horse. (can I eliminate that split second teleport making it super obvious they just died?)
Both versions are based on recommendations I found here on devforum.
I’m very close! Any ideas where I went wrong? Can I shut down death?
Version 2:
Latest code. For Version 2, I probably don’t need to move animate, since I am killing the character intentionally.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local mountModule = require(ReplicatedStorage.MountManagement)
local test = game.Workspace.TestHorse
local db = true --debounce
test.PrimaryPart.Touched:Connect(function (hit)
if db then
db = false
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
game.Players.CharacterAutoLoads = false --VERSION 2
mountModule.prepMount(plr,test)
plr:LoadCharacter() --VERSION 2
plr.PlayerGui.UpdateCam:FireClient(plr,test.PrimaryPart)
test.Name = plr.Name
local animate = plr.Character.Animate
plr.Character = test --causes death
animate.Parent = plr.Character
end
wait(1)
db = true
game.Players.CharacterAutoLoads = true --VERSION 2
end
end)