I am using this script to attach the gun to the hand, then to the head (this will be done when players presses Right Click, for testing purposes I kept it simple)
Server Script
local tool = script.Parent
local handle = tool:WaitForChild("Hrandle")
local aim = tool:WaitForChild("Aim")
local char
local rightHand
local head
local equipped
local aiming = false
local loaded = false
tool.Equipped:Connect(function()
if not loaded then
char = tool.Parent
rightHand = char:WaitForChild("RightHand")
head = char:WaitForChild("Head")
end
equipped = true
end)
repeat task.wait() until equipped == true
handle.CFrame = rightHand.CFrame
local joint = Instance.new("Motor6D")
joint.Part0 = handle
joint.Part1 = rightHand
joint.Parent = handle
task.wait(3)
joint:Destroy()
aim.CFrame = head.CFrame
local joint = Instance.new("Motor6D")
joint.Part0 = aim
joint.Part1 = head
joint.Parent = aim
The problem is, as you can see in the video, the hand doesn’t follow the gun (I know there is no code to do that now, I have no idea where to start).
I want it so that no matter where the gun goes, the whole right arm tries to reach to it, hold it.
This is because the hand is literally jointed with a useless Motor6D (that I think should be a weld).
The reason why it’s not working is because the hand is jointed to something else with more mass, causing the part to follow the hand, which is clearly what you don’t want here.
So, you can either incline the mass of the other part or do this manually by setting the CFrame.
But again, I just want to say if the hand goes to the gun, the hand will be detached from the arm or bring the whole character with it, so you’ll need to create an animation.
I tried to modify the script in that post, replacing mouse hit pos with gun’s handle, but the hand moved just up and down, and didn’t actually rotate inwards to the gun. Also it wasn’t really following the gun, it was following the camera, meaning the little shakes of the gun wouldn’t affect the hand, it would be still
Yes, but what’s shown in the video is easily done by just a normal tool with a handle (I already tried it and it worked with another script). I want the player to be able to aim with a sight, when pressing right mouse button - this is what I cant achieve.
Ah, that. You might want to look into EasyFirstPerson as it has an AimOffset value inside its script. I’m not sure how else to do that without a viewmodel, though
It looks like it doesn’t have sight aim feature, what it has I already can do without it. + it has tons of bugs, and it uses a viewmodel, which I would really like to avoid
Yeah not at all what I’m looking for, I already have a script like this that moves the hand with the camera
if moveHand then
local cameralookvectorY = workspace.CurrentCamera.CFrame.lookVector.Y
local radian = math.asin(cameralookvectorY)
char.RightUpperArm.RightShoulder.C0 = c0*CFrame.fromEulerAnglesYXZ(radian,0,0)
end
end
Anyway I decided to do what I want with precise animations. I could’ve done it already If I spent on it 1/4 of the time I spent on looking an unnecessary perfect solution.