So I’m making a move and I adjust the player’s CFrame that is nearest to me, and when I’m standing still it moves the player correctly, but when I’m moving it moves the player incorrectly.
Video
Script
local Particles = require(game.ServerStorage.Particles)
local Hitbox = require(game.ServerStorage.Hitbox)
game.ReplicatedStorage.t.OnServerEvent:Connect(function(Player)
local Character = Player.Character
local Kick = Character.Humanoid:LoadAnimation(script.Kick)
Kick:Play()
Particles.AkumaFeet(Player, false)
local Hit
for i,v in pairs(workspace:GetChildren()) do
if v:FindFirstChild("Humanoid") and v ~= Character then
local check = v.Humanoid:GetState()
if check ~= Enum.HumanoidStateType.Dead then
if (Character.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude <= 7 then
Hit = v
end
end
end
end
if Hit ~= nil then
Character.HumanoidRootPart.Anchored = true
Hit.HumanoidRootPart.Anchored = true
local KickHit = Hit.Humanoid:LoadAnimation(script.KickHit)
KickHit:Play()
KickHit:AdjustSpeed(.82)
Hit.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0, 0, -3)
Hit.HumanoidRootPart.CFrame = CFrame.lookAt(Hit.HumanoidRootPart.Position, Character.HumanoidRootPart.Position)
spawn(function()
for i = 1,3 do
if i == 1 then
wait(.25)
end
Hitbox.TakeDamage(Hit, 20, false)-- + script.Parent.GraceAdd.Value)
Particles.Hit(Hit)
wait(.55)
end
end)
end
Kick.Stopped:Wait()
Particles.AkumaFeet(Player, true)
Character.HumanoidRootPart.Anchored = false
if Hit ~= nil then
Hit.HumanoidRootPart.Anchored = false
end
end)
I really need help on how to fix this.