How can I do something along the lines of tweening the player’s orientation to face a target part?
BONUS
How can I make it constant (so if the target moves, the player continues to look at them)?
How can I do something along the lines of tweening the player’s orientation to face a target part?
BONUS
How can I make it constant (so if the target moves, the player continues to look at them)?
Use a render stepped function and set the player’s humanoidrootpart’s cframe to face them like this:
local hrp = game.Players.LocalPlayer.Character.HumanoidRootPart
local target = --target here
hrp.CFrame = CFrame.new(hrp.CFrame.Position, target.Character.HumanoidRootPart.CFrame.Position)
Follow up for @Kaid3n22 's post, since OP wanted to tween
local Tweens = game:GetService("TweenService")
local Run = game:GetService("RunService")
local Char = game.Players.Localplayer.Character or game.Players.Localplayer.CharacterAdded:Wait()
local target = --reference target
Run.RenderStepped:Connect(function()
local GoalCF = CFrame.lookat(Char.PrimaryPart.Position, target.PrimaryPart.Position)
local rotate = Tweens:Create(Char.PrimaryPart, TweenInfo.new(.2,Enum.EasingStyle.Cubic), {CFrame = GoalCF})
rotate:Play()
end)
i edited it a little to suit my needs, also i decided i didnt want it to be constant:
--tween character aim at target
local GoalCF = CFrame.lookat(plr.Character.HumanoidRootPart.Position, enemy:FindFirstChild("HumanoidRootPart").Position)
--^^^Erroring line: "Attempt to call nil value"
local rotate = tweenServ:Create(plr.Character.HumanoidRootPart, TweenInfo.new(.2,Enum.EasingStyle.Cubic), {CFrame = GoalCF})
rotate:Play()
Which part of that is the nil value? I don’t see how it’d be nil either
LOL NVM it was capitalizing in CFrame.lookat its lookAt lol