Hello!
So, I need some help on this death system that I am creating. Some of it has to do with CFrame. Let me get to the point, the point is, is that everytime the character would move a lot, and when the death function would trigger, the CFrame would push the player into another coordinate frame of the game, basically making the character face backwards instead of forwards, which is not what I want.
I have some videos that should put things in context and make the situation more understandable. :
Whats happening in this video is that when the player is rapidly moving while the death function triggers, what happens is instead of the character’s CFrame moving infront of the player’s screen, the character’s CFrame moves at the back of the screen. I don’t know if there is any fix for this? If so, I am curious.
robloxapp-20230504-0829216.wmv (317.9 KB)
The last video I have is of the character not rapidly moving while the death function triggers. If the character stays still, then the character will pop up infront of the screen, else the character will go to the back of the screen, which is what the first video is about. This video is also what I want the player’s death to be all the time, infront of the screen, not at the back of the screen.
robloxapp-20230504-0855261.wmv (224.1 KB)
(If you need me to elaborate more on the problem, please let me know.)
Finally, here is the code. This code is stored inside of a ModuleScript. This code is the program for making the death happen.
local deathmdle = {
tme = .5,
tmeinout = .3,
othermaxforce = 99999999,
huge = math.huge,
waime = .55,
velocity = 150
}
local player = game:GetService("Players").LocalPlayer
repeat task.wait() until player.Character
local character = player.Character or player.CharacterAdded:Wait()
local animations = script:WaitForChild("ANIMATIONS")
local hrp = character:WaitForChild("HumanoidRootPart")
local controls = require(player.PlayerScripts:WaitForChild("ControlScript")["GAMEPADS/KEYBOARD"])
local camera = require(player.PlayerScripts:WaitForChild("CameraScript").CameraControl)
local sounds = workspace.sounds
local t1
local t2
local anim = {
death = character:WaitForChild("Humanoid").Animator:LoadAnimation(animations.death_anim)
}
function deathmdle.CharacterDeath (self)
task.wait()
local self = deathmdle
controls.DisableController()
for i,v in pairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do
v:Stop(0)
end
local deathvl = Instance.new("BodyVelocity", hrp)
deathvl.MaxForce = Vector3.new(0,self.othermaxforce,0)
deathvl.Velocity = Vector3.new(0,0,0)
t1 = game:GetService("TweenService"):Create(deathvl, TweenInfo.new(self.tme), {Velocity = Vector3.new(0,self.velocity,0)})
t2 = game:GetService("TweenService"):Create(deathvl, TweenInfo.new(self.tmeinout), {Velocity = Vector3.new(0,-self.velocity,0)})
for _, v in pairs(character:GetChildren()) do
if v:IsA("BasePart") or v:IsA("Part") then
v.CanCollide = false
end
end
for _, v in pairs(character:GetChildren()) do
if v:IsA("Accessory") then
for i, parts in pairs(v:GetChildren()) do
if parts:IsA("Part") then
parts.CanCollide = false
end
end
end
end
sounds.death:Play()
anim.death:Play(0)
hrp.CFrame *= CFrame.fromEulerAnglesXYZ(math.rad(hrp.Orientation.X),math.rad(-90),math.rad(hrp.Orientation.Z)) * CFrame.new(0,0,-10)
task.wait(self.tme)
deathvl.MaxForce = Vector3.new(0,self.huge,0)
t1:Play()
t1.Completed:Wait()
t2:Play()
wait(self.waime)
camera.DisableCamera()
return self
end
return deathmdle
I appreciate all kinds of help. Thank you.

