Help of CFrame to Character Hand

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Pickaxe when on equip to be facing the right way and in right position
  2. What is the issue? Include screenshots / videos if possible!
    Pickaxe no cooperate with me, I suck at CFrame
  3. What solutions have you tried so far?
    I tried looking at API Reference, just cant seem to get it right

So basically I’m here more or less for two things

  1. In my game, I’m going to make it where you can (un)equip a pickaxe, I’m not doing a tool. There are a few reasons I’m not doing a tool.
    a) It’s going to be the only thing a player uses in the game
    b) I plan on making this game fully Xbox Compatible, having a toll will take away being able to use RB and LB buttons for anything game wise
    c) I think it looks cooler

  2. For some reason the animation I have for equipping the pickaxe glitches out and skips a frame, but this will probably be posted in a different post for animation support

This is my Test Pickaxe that I’m using: Fairly simple
RobloxStudioBeta_BFg9ZqJpGO
RobloxStudioBeta_vhLiDB2tjK

I have it where when you join it gets placed on your back as such:
RobloxStudioBeta_r81d5sT2Fy
with this code

local playerpart = Player.Character.UpperTorso
local cf = CFrame.new(0,0,0.525)
local ori = CFrame.fromOrientation(0.15,0,2.3)
ThisPick.PrimaryPart.CFrame = playerpart.CFrame*cf*ori
module.NewWeld(playerpart,ThisPick.PrimaryPart,'CharacterWeld')

Now my inquiry will be this


I want it to where the pick part faces forward
and this is the code I have for it

local playerpart = Player.Character.RightHand
local cf = CFrame.new(0,0.4,-1.1)
local ori = CFrame.fromOrientation(200,-0.2,0)
			
local GetEquip = module.MainModule.Animations.EquipPickaxe
local GetIdle = module.MainModule.Animations.PickIdle
			
local EquipTrack = Player.Character.Humanoid.Animator:LoadAnimation(GetEquip)
local IdleTrack = Player.Character.Humanoid.Animator:LoadAnimation(GetIdle)
EquipTrack:Play(0,1)
			
			
			
EquipTrack.KeyframeReached:connect(function(neme)
	if neme == 'GetPick' then
		GetPick.PrimaryPart.CharacterWeld:Destroy()
		GetPick.PrimaryPart.CFrame = playerpart.CFrame*cf*ori
		module.NewWeld(playerpart,GetPick.PrimaryPart,'CharacterWeld')
		GetPick.PrimaryPart.CFrame = playerpart.CFrame*cf*ori
	elseif neme == 'Equip' then
		GetPick.PrimaryPart.CFrame = playerpart.CFrame*cf*ori
		IdleTrack:Play(0,1)
		EquipTrack:Stop()
	end
end)

So any help would be appreciated

Try downloading this plugin and using it to adjust the grip of the tool.

1 Like

Unfortunately this will not help me.
As specified in my post, I’m not using an actual “Tool”
But in fact a model containing parts to Pickaxe

1 Like

Oh whoops, sorry. You can use CFrame.LookVector to get what direction the RightHand or HumanoidRootPart is facing, then use that to determine the CFrame for the pickaxe.

1 Like

If you could give me an example,
Right now as in the video, I have it where it goes into the player hand, but positioning the CFrame of the handle including where I want the handle to sit in the players hand and the rotation of the pickaxe as a whole.
Since changing the Rotation of only the handle the Pick that’s welded to the Handle doesn’t follow it, so I have to resort to the CFrame

I don’t know what aspects of the CFrame itself I have to tinker with to be able to do that

1 Like

Yes, I can create an example when I can get on my computer. For now if you want, you can read about CFrame here:
https://developer.roblox.com/en-us/api-reference/datatype/CFrame

1 Like

I’ll take a dive into that and keep on with trial and error
but here’s a video of me trying to do it

Question, does the pickaxe change orientation based on which way you’re facing when you equip it? Or does it face the same way every time regardless of which way you’re facing?

1 Like

What I do is when the Keyframe Reached of “GetPick” I destroy the weld the Pickaxe has (Which is welded to UpperTorso) then I set the CFrame of the pickaxe to the hand or well the spot I want it in and then Create a new weld to the characters hand, and for insurance I set it again after the weld

EquipTrack.KeyframeReached:connect(function(neme)
	if neme == 'GetPick' then
		GetPick.PrimaryPart.CharacterWeld:Destroy()
		GetPick.PrimaryPart.CFrame = playerpart.CFrame*cf*ori
		module.NewWeld(playerpart,GetPick.PrimaryPart,'CharacterWeld')
		GetPick.PrimaryPart.CFrame = playerpart.CFrame*cf*ori
	elseif neme == 'Equip' then
		GetPick.PrimaryPart.CFrame = playerpart.CFrame*cf*ori
		IdleTrack:Play(0,1)
		EquipTrack:Stop()
	end
end)

The pickaxe goes to the same spot no matter which way I’m facing
it’s just getting it to the right position and rotation

and by same spot I mean same spot correlating to the character so If i face one way itl go in my face
face another same result

Could you remove ori from the CFrame math in the Equipping function and show me what the result of equipping looks like?

1 Like

Here ya go

local ori = CFrame.fromOrientation(math.rad(90), 0, math.rad(90))

local ori = CFrame.fromOrientation(math.rad(90), math.rad(90), 0)

Add ori back to the math and change the variable to both of these. I’m pretty sure one of these works just not sure which.

1 Like

I think I see what I need to do now
So Just keep messing with it like that?

Yep, you should eventually find the right CFrame.

1 Like

It works now!
RobloxStudioBeta_y8Bs3xKgrA

Now should I do the same thing for when it goes on to the back? with the math.rad?
because i kinda have the same concept on the back
I just feel like I could make the code and the placement of the pickaxe cleaner

local playerpart = Player.Character.UpperTorso
local cf = CFrame.new(0,0,0.525)
local ori = CFrame.fromOrientation(0.15,0,2.3)
ThisPick.PrimaryPart.CFrame = playerpart.CFrame*cf*ori
module.NewWeld(playerpart,ThisPick.PrimaryPart,'CharacterWeld')

Yes, you should, so you have a baseline for any future tools you make.

1 Like

Thanks man, I really appreciate the help, I was waiting for hours.
If I could upvote your profile I would

1 Like