I want a player to be pointing the same direction as I am, without interrupting the script.
Here is a script I tried:
thread = coroutine.create(function()
while FinisherEnabled do
-- The "EnemyFinisherTP" is a part that the player is teleported to.
NearestChar.HumanoidRootPart.CFrame = PlrChar.EnemyFinisherTP.CFrame
wait()
end
end)
FinisherEnabled = true
coroutine.resume(thread)
and here is a video of how it worked ingame:
It worked for a second, but it doesn’t update the CFrame.
I got it. the reason why the dummy is not moving is probably because it died. when the npc die the npc joints will destroyed. If you CFraming the npc RootPart when it died the body will not follow the RootPart. Set “BreakJointsOnDeath” in the npc humanoid property to false
local StabDebounce = false
local FinisherEnabled = false
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Remotes = ReplicatedStorage:WaitForChild('Remotes')
local thread
local module = {}
local function getNearestPlayer(plrPos, Plr, Distance)
local List = workspace:GetChildren()
local Character
for i, v in List do
if v:IsA('Model') and v:FindFirstChild('Humanoid') and v ~= Plr then
if (v.PrimaryPart.Position - plrPos).Magnitude <= Distance then
Character = v
end
end
end
return Character
end
function module.Move5(Player)
local NickiUserAnim, NickiEnemyAnim = Instance.new('Animation'), Instance.new('Animation')
NickiUserAnim.AnimationId = "rbxassetid://11794164119"
NickiEnemyAnim.AnimationId = "rbxassetid://11794169552"
local PlrChar = Player.Character
local NearestChar = getNearestPlayer(PlrChar.PrimaryPart.Position, PlrChar, 5)
if NearestChar then
local EnemyHumanoid = NearestChar:FindFirstChild('Humanoid')
if EnemyHumanoid.Health == 0 then
return
end
if EnemyHumanoid.Health <= 15 then
thread = coroutine.create(function()
while FinisherEnabled do
NearestChar.HumanoidRootPart.CFrame = PlrChar.EnemyFinisherTP.CFrame
wait()
end
end)
local NickiFinisherSounds = {
["ImNicki"] = Instance.new('Sound', Player.Character:FindFirstChild('Head')),
["BloodSplatter"] = Instance.new('Sound', NearestChar.PrimaryPart)
}
NickiFinisherSounds.ImNicki.SoundId = "rbxassetid://11793817794"
NickiFinisherSounds.ImNicki.Volume = 1
NickiFinisherSounds.BloodSplatter.SoundId = "rbxassetid://330595293"
NickiFinisherSounds.BloodSplatter.Volume = 1
Remotes:WaitForChild('DisableMoveset'):FireClient(Player, true)
if game.Players:GetPlayerFromCharacter(NearestChar) then
Remotes:WaitForChild('DisableMoveset'):FireClient(game.Players:GetPlayerFromCharacter(NearestChar), true)
end
Remotes:WaitForChild('DisableResetCallback'):FireClient(Player, true)
if game.Players:GetPlayerFromCharacter(NearestChar) then
Remotes:WaitForChild('DisableResetCallback'):FireClient(game.Players:GetPlayerFromCharacter(NearestChar), true)
end
FinisherEnabled = true
coroutine.resume(thread)
Player.Character.PrimaryPart.Anchored = true
NearestChar.PrimaryPart.Anchored = true
local NickiReadyUser, NickiReadyEnemy = Player.Character:FindFirstChild('Humanoid').Animator:LoadAnimation(NickiUserAnim), EnemyHumanoid.Animator:LoadAnimation(NickiEnemyAnim)
NickiReadyUser:Play()
NickiReadyEnemy:Play()
wait(1)
NickiFinisherSounds.ImNicki:Play()
wait(4)
Remotes:WaitForChild('DisableMoveset'):FireClient(Player, false)
if game.Players:GetPlayerFromCharacter(NearestChar) then
Remotes:WaitForChild('DisableMoveset'):FireClient(game.Players:GetPlayerFromCharacter(NearestChar), false)
end
Remotes:WaitForChild('DisableResetCallback'):FireClient(Player, false)
if game.Players:GetPlayerFromCharacter(NearestChar) then
Remotes:WaitForChild('DisableResetCallback'):FireClient(game.Players:GetPlayerFromCharacter(NearestChar), false)
end
FinisherEnabled = false
NickiFinisherSounds.BloodSplatter:Play()
EnemyHumanoid:TakeDamage(EnemyHumanoid.Health)
Player.Character.PrimaryPart.Anchored = false
NearestChar.PrimaryPart.Anchored = false
end
end
end
return module
It’s a very long script, and it’s a ModuleScript if that helps.
I see that when the npc die the body break into piece so the body will not follow to humanoidrootpart. also set “BreakJointsOnDeath” in npc humanoid property to false
No. Don’t Anchor the NPC HumanoidRootPart, Create a new BodyVelocity on a NPC HumanoidRootPart and set the Velocity to Vector3.new() and MaxForce to Vector3.new(9e9, 9e9, 9e9).
local StabDebounce = false
local FinisherEnabled = false
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Remotes = ReplicatedStorage:WaitForChild('Remotes')
local thread
local module = {}
local function getNearestPlayer(plrPos, Plr, Distance)
local List = workspace:GetChildren()
local Character
for i, v in List do
if v:IsA('Model') and v:FindFirstChild('Humanoid') and v ~= Plr then
if (v.PrimaryPart.Position - plrPos).Magnitude <= Distance then
Character = v
end
end
end
return Character
end
function module.Move5(Player)
local NickiUserAnim, NickiEnemyAnim = Instance.new('Animation'), Instance.new('Animation')
NickiUserAnim.AnimationId = "rbxassetid://11794164119"
NickiEnemyAnim.AnimationId = "rbxassetid://11794169552"
local PlrChar = Player.Character
local NearestChar = getNearestPlayer(PlrChar.PrimaryPart.Position, PlrChar, 5)
if NearestChar then
local EnemyHumanoid = NearestChar:FindFirstChild('Humanoid')
if EnemyHumanoid.Health == 0 then
return
end
if EnemyHumanoid.Health <= 15 then
thread = coroutine.create(function()
while FinisherEnabled do
NearestChar.HumanoidRootPart.CFrame = PlrChar.EnemyFinisherTP.CFrame
wait()
end
end)
local NickiFinisherSounds = {
["ImNicki"] = Instance.new('Sound', Player.Character:FindFirstChild('Head')),
["BloodSplatter"] = Instance.new('Sound', NearestChar.PrimaryPart)
}
NickiFinisherSounds.ImNicki.SoundId = "rbxassetid://11793817794"
NickiFinisherSounds.ImNicki.Volume = 1
NickiFinisherSounds.BloodSplatter.SoundId = "rbxassetid://330595293"
NickiFinisherSounds.BloodSplatter.Volume = 1
Remotes:WaitForChild('DisableMoveset'):FireClient(Player, true)
if game.Players:GetPlayerFromCharacter(NearestChar) then
Remotes:WaitForChild('DisableMoveset'):FireClient(game.Players:GetPlayerFromCharacter(NearestChar), true)
end
Remotes:WaitForChild('DisableResetCallback'):FireClient(Player, true)
if game.Players:GetPlayerFromCharacter(NearestChar) then
Remotes:WaitForChild('DisableResetCallback'):FireClient(game.Players:GetPlayerFromCharacter(NearestChar), true)
end
FinisherEnabled = true
coroutine.resume(thread)
local BV = Instance.new("BodyVelocity", Player.Character.PrimaryPart)
local BV2 = Instance.new("BodyVelocity",
NearestChar.PrimaryPart)
BV.Velocity = Vector3.new()
BV.MaxForce = Vector3.new(9e9, 9e9, 9e9)
BV2.Velocity = Vector3.new()
BV2.MaxForce = Vector3.new(9e9, 9e9, 9e9)
local NickiReadyUser, NickiReadyEnemy = Player.Character:FindFirstChild('Humanoid').Animator:LoadAnimation(NickiUserAnim), EnemyHumanoid.Animator:LoadAnimation(NickiEnemyAnim)
NickiReadyUser:Play()
NickiReadyEnemy:Play()
wait(1)
NickiFinisherSounds.ImNicki:Play()
wait(4)
Remotes:WaitForChild('DisableMoveset'):FireClient(Player, false)
if game.Players:GetPlayerFromCharacter(NearestChar) then
Remotes:WaitForChild('DisableMoveset'):FireClient(game.Players:GetPlayerFromCharacter(NearestChar), false)
end
Remotes:WaitForChild('DisableResetCallback'):FireClient(Player, false)
if game.Players:GetPlayerFromCharacter(NearestChar) then
Remotes:WaitForChild('DisableResetCallback'):FireClient(game.Players:GetPlayerFromCharacter(NearestChar), false)
end
FinisherEnabled = false
NickiFinisherSounds.BloodSplatter:Play()
EnemyHumanoid:TakeDamage(EnemyHumanoid.Health)
BV:Destroy()
BV2:Destroy()
end
end
end
return module