Help With Getting My Character to Point to Cursor

  1. What do you want to achieve?
    I am trying to get my character to point to my cursor
  2. What is the issue?
    the character is not pointing to the cursor when an animation plays
  3. What solutions have you tried so far?
    I do not know the problem yet but it is either:
    a problem with Worldspace or Objectspace
    a problem with animations (i suspect the rotation of the torso in the bike animation)
    a problem with how I set the Motor6d

this is how i am doing it

local RootPart = Character:WaitForChild("HumanoidRootPart")
local Torso = Character:WaitForChild("Torso")
local RightShoulder : Motor6D = Torso:WaitForChild("Right Shoulder")
local Offset = CFrame.new(1,0.5,0) * CFrame.Angles(0,math.rad(90),math.rad(90))

local PlacePart = Instance.new("Part",workspace)
PlacePart.Anchored = true
PlacePart.BrickColor = BrickColor.new("Really red")
PlacePart.Size = Vector3.new(1,1,1)
PlacePart.CanCollide = false
PlacePart.CanQuery = false

local PointPart = Instance.new("Part",workspace)
PointPart.Anchored = true
PointPart.BrickColor = BrickColor.new("Really red")
PointPart.Size = Vector3.new(1, 1,2)
PointPart.Transparency = 0.7
PointPart.CanCollide = false
PointPart.CanQuery = false


while ResetArmsTrack == nil do
	task.wait()
end
ResetArmsTrack:Play()
RunService.RenderStepped:Connect(function()
	PlacePart.Position = Mouse.Hit.Position
	local Direction : Vector3 = CFrame.lookAt(Character["Right Arm"].Position,Mouse.Hit.Position)
	PointPart.CFrame = Direction
	local X,Y,Z = RootPart.CFrame:ToObjectSpace(Direction):ToOrientation()
	RightShoulder.C0 = Offset * CFrame.Angles(Y,0,X)
end)

I have a reset arms animation that plays to stop other animations changing the position of the arm
idk why I had to do “RightShoulder.C0 = Offset * CFrame.Angles(Y,0,X)” I just did trial and error
I think its because the front of the arm isn’t where the hand would be

i highly suspect the animation is causing the problem because it rotates the torso and i am basing the object space of it ( local X,Y,Z = RootPart.CFrame:ToObjectSpace(Direction):ToOrientation() )

as u can see it get messed up as soon as i get onto the bike

1 Like

correct. it is in fact the animation causing the problem.
you can try manually setting the arm’s CFrame

i think it works like this, can’t exactly remember

Part1.CFrame = Part0.CFrame * C0 * C1:Inverse()

sorry but could you explain it so i can implement it

Animation blending/weight is causing the arm to lerp back to where the arm originally is in the bike animation.

You could fix this by setting the weight of the bike animation to zero.

instead of

Weld.C0 = (insert CFrame here)

you can do

Weld.Part1.CFrame = Weld.Part0.CFrame * Weld.C0 * Weld.C1:Inverse()

so animations don’t interfere
and maybe disable the weld

the example in the link did not work so i used adjustweight()
‘’‘lua
local BikeIdle = Instance.new(“Animation”)
BikeIdle.AnimationId = “rbxassetid://15027342446”
local BikeIdleTrack : AnimationTrack= Animator:LoadAnimation(BikeIdle)
BikeIdleTrack:AdjustWeight(0)
‘’’
but it didnt change anything
i tried setting it to 0.001 too because i hear that 0 doesnt work

i still dont understand what part0 and c1 are

weld properties
that’s what they are

ok well ig i wasn’t clear enough
anyways, here’s a little code block to help you understand what i meant

local Part1 = RightShoulder.Part1
local Part0 = RightShoulder.Part0
local C0 = Offset * CFrame.Angles(Y,0,X)
if Part1 and Part0 then
	RightShoulder.Enabled = false
	Part1.CFrame = Part0.CFrame * C0 * RightShoulder.C1:Inverse()
else
	RightShoulder.Enabled = true
end

I tried that but this was the result


with this script:

local RootPart = Character:WaitForChild("HumanoidRootPart")
local Torso = Character:WaitForChild("Torso")
local RightShoulder : Motor6D = Torso:WaitForChild("Right Shoulder")
local Offset = CFrame.new(1,0.5,0) * CFrame.Angles(0,math.rad(90),math.rad(90))

local PlacePart = Instance.new("Part",workspace)
PlacePart.Anchored = true
PlacePart.BrickColor = BrickColor.new("Really red")
PlacePart.Size = Vector3.new(1,1,1)
PlacePart.CanCollide = false
PlacePart.CanQuery = false

local PointPart = Instance.new("Part",workspace)
PointPart.Anchored = true
PointPart.BrickColor = BrickColor.new("Really red")
PointPart.Size = Vector3.new(1, 1,2)
PointPart.Transparency = 0.7
PointPart.CanCollide = false
PointPart.CanQuery = false


while ResetArmsTrack == nil do task.wait() end
ResetArmsTrack:Play()
RunService.RenderStepped:Connect(function()
	PlacePart.Position = Mouse.Hit.Position
	local Direction : Vector3 = CFrame.lookAt(Character["Right Arm"].Position,Mouse.Hit.Position)
	PointPart.CFrame = Direction
	local X,Y,Z = RootPart.CFrame:ToObjectSpace(Direction):ToOrientation()
	RightShoulder.C0 = Offset * CFrame.Angles(Y,0,X)
	local C0 = Offset * CFrame.Angles(Y,0,X)
	local Part1 = RightShoulder.Part1
	local Part0 = RightShoulder.Part0
	if Part1 and Part0 then
		RightShoulder.Enabled = false
		Part1.CFrame = Part0.CFrame * C0 * RightShoulder.C1:Inverse()
	else
		RightShoulder.Enabled = true
	end
end)

I think I got it
It’s because your torso is facing downwards.
Part0 for all the welds is Torso

honestly, i’m not sure how to fix this, but ig you can do this

local RootPart = Character:WaitForChild("HumanoidRootPart")
local Torso = Character:WaitForChild("Torso")
local RightShoulder : Motor6D = Torso:WaitForChild("Right Shoulder")
local Offset = CFrame.new(1,0.5,0) * CFrame.Angles(0,math.rad(90),math.rad(90))

local PlacePart = Instance.new("Part",workspace)
PlacePart.Anchored = true
PlacePart.BrickColor = BrickColor.new("Really red")
PlacePart.Size = Vector3.new(1,1,1)
PlacePart.CanCollide = false
PlacePart.CanQuery = false

local PointPart = Instance.new("Part",workspace)
PointPart.Anchored = true
PointPart.BrickColor = BrickColor.new("Really red")
PointPart.Size = Vector3.new(1, 1,2)
PointPart.Transparency = 0.7
PointPart.CanCollide = false
PointPart.CanQuery = false


while ResetArmsTrack == nil do task.wait() end
ResetArmsTrack:Play()
RunService.RenderStepped:Connect(function()
	PlacePart.Position = Mouse.Hit.Position
	local Direction : Vector3 = CFrame.lookAt(Character["Right Arm"].Position,Mouse.Hit.Position)
	PointPart.CFrame = Direction
	local X,Y,Z = RootPart.CFrame:ToObjectSpace(Direction):ToOrientation()
	RightShoulder.C0 = Offset * CFrame.Angles(Y,0,X)
	local C0 = Offset * CFrame.Angles(Y,0,X)
	local Part1 = RightShoulder.Part1
	local Part0 = RightShoulder.Part0
	if Part1 and Part0 then
		RightShoulder.Enabled = false
		Part1.CFrame = CFrame.new(Part0.Position) * CFrame.Angles(0, Part0.Orientation.Y, 0) * C0 * RightShoulder.C1:Inverse()
	else
		RightShoulder.Enabled = true
	end
end)

I ended up just faking the arm in the end but thanks for your help though

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.