How do i make a aimable gun with toolgrip

  1. What do you want to achieve?
    I want to Aim Using ToolGrip Or Something Similar
  2. What is the issue?
    I Tried To Do it with animations but it didnt line up,
  3. What solutions have you tried so far?
    i tried using toObjectSpace like how i did it on viewmodels but it kept Rotating
local Tool = script.Parent
local AimPart = Tool:WaitForChild("AimPart")
local Camera = workspace.CurrentCamera
local Aiming = false
--Skip until Run Service because i dont want to spoil my whole script --

game:GetService("RunService").RenderStepped:Connect(function()
if Aiming then
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
Camera.CFrame = Camera.CFrame:ToObjectSpace(AimPart.CFrame)
else
game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
end
end)

One solution could be to use a WeldConstraint to attach the tool to the character’s hand, which will allow the tool to move with the hand and line up properly when the character aims.

So, basically, it’ll be like this

local Tool = script.Parent
local AimPart = Tool:WaitForChild("AimPart")
local Camera = workspace.CurrentCamera
local Aiming = false


local Weld = Instance.new("WeldConstraint")
Weld.Parent = Tool.Handle
Weld.Part0 = Tool.Handle
Weld.Part1 = game.Players.LocalPlayer.Character.RightHand

Tool.Activated:Connect(function()
    Aiming = not Aiming
end)

game:GetService("RunService").RenderStepped:Connect(function()
    if Aiming then
        game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
        Camera.CFrame = Camera.CFrame:ToObjectSpace(AimPart.CFrame)
    else
        game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic
    end
end)
1 Like

ill test it in 10 minutes
if it works ill mark your post as the solution

Thanks

it doesnt work but i found another solution thanks tho

What is the solution to your problem?