You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Rotate a part based off the direction that the player is facing
-
What is the issue? So I’m currently making a combat system, which involves knocking back players at the last hit, I also added effects when the player is knocked back, but it’s not facing the right direction I’m wanting it to. I’m not that great at CFrame as I haven’t been practicing much about it. Here’s the video about the issue: https://gyazo.com/5b8a26cc0830f440cced7c082c52c4a8
-
What solutions have you tried so far? I’ve tried looking through pretty much every threads I could regarding this issue, but none seems to work for me
Here’s the code that I use to change the CFrame of the effect:
local direction = plr.Character.HumanoidRootPart.Position + plr.Character.HumanoidRootPart.CFrame.LookVector * plr.Character.HumanoidRootPart.Position.Magnitude
local kbEffect = Meshes:WaitForChild("kbEffect"):Clone()
kbEffect.Parent = enemyHrp
kbEffect.CFrame = CFrame.lookAt(Character.HumanoidRootPart.Position, direction)
kbEffect.Orientation = Character.HumanoidRootPart.CFrame.LookVector * Vector3.new(90, 0, 0)
print(direction)
local weld = Instance.new("ManualWeld")
weld.Part0 = kbEffect
weld.Part1 = enemyHrp
weld.C0 = weld.Part0.CFrame:toObjectSpace(weld.Part1.CFrame)
weld.Parent = weld.Part0
Debris:AddItem(kbEffect, .75)
local goal = {}
goal.Size = kbEffect.Size + Vector3.new(5, 0, 5)
local info = TweenInfo.new(.5)
local tween = TweenService:Create(kbEffect, info, goal)
tween:Play()
Any help is appreciated!