Why isn't this working?

Is this close?
image

Try doing 90 90 0

90 degrees are your best friend, just keep messing around with increments of 90 (-180,-90,0,90,180) on the three numbers and you will eventually get there

1 Like

Got it to face up right, but’s its wonky for some reason.
image

That’s because the tool grip’s position needs to be changed as well

Replace the tool grip code snippet with this new one

--Rotate grip!
local gripOrientation = CFrame.Angles(math.rad(90),math.rad(90),math.rad(0))
tool.Grip = CFrame.new(tool.Grip.Position) * gripOrientation)
--Position grip!
local gripPos = tool.Grip.Position
local gripOffset = {0,0,0}
local newGripPos = Vector3.new(gripPos.X+gripOffset[1],gripPos.Y+gripOffset[2],gripPos.Z+gripOffset[3])
tool.Grip = CFrame.new(newGripPos) * gripOrientation

You will have to tinker with the numbers in gripOffset

Try these numbers in gripOffset:
-0.5 -0.5, -0.5

I get this:

Players.captan40000.Backpack.MartinHenry.LocalScript:25: attempt to perform arithmetic (add) on number and nil - Client - LocalScript:25

Sorry. I have to sleep, it’s midnight. I’ll be a few hours, sorry!

1 Like

Back. Do you know why this is happening?

Can you show the code you have currently?

1 Like

I accidently turned off my PC without saving, sorry:

local Player = game:GetService("Players").LocalPlayer
local CharacterAdded = Player.Character or Player.CharacterAdded:Wait()
local Character = Player.Character

--Get the tool and then get the model of your tool you are using.
--If you do not have your tool part(s) wrapped in a model, it's a good idea to do so. Make sure to set the Model.PrimaryPart to a part that stays static and has no animations on it
local tool = script.Parent
local yourToolModel = tool["MartiniHenry"]

local UIS = game:GetService("UserInputService")
--Create a handle (make sure to have UseHandle checked on the tool)
local handle = Instance.new("Part")
handle.Name = "Handle"
handle.Transparency = 1
handle.CanCollide = false
handle.Size = Vector3.new(0.1,0.1,0.1)
handle.Parent = tool
 
--Rotate grip!
local gripOrientation = CFrame.Angles(math.rad(90),math.rad(90),math.rad(0))
tool.Grip = CFrame.new(tool.Grip.Position) * gripOrientation
--Position grip!
local gripPos = tool.Grip.Position
local gripOffset = {0,0,0}
local newGripPos = Vector3.new(gripPos.X+gripOffset[1],gripPos.Y+gripOffset[2],gripPos.Z+gripOffset[3])
tool.Grip = CFrame.new(newGripPos) * gripOrientation
--Line up the model with the handle
yourToolModel:SetPrimaryPartCFrame(handle.CFrame)

--Makes the tool model attach to the handle with a WeldConstraint
local newWeld = Instance.new("WeldConstraint")
newWeld.Part0 = handle
newWeld.Part1 = yourToolModel.PrimaryPart
newWeld.Parent = handle

UIS.InputBegan:Connect(function(Input, GP)
	if Input.KeyCode == Enum.KeyCode.R and not GP then
		print("starting")
		local humanoid = Character:FindFirstChildOfClass("Humanoid")
		if humanoid then
			local Animation = Instance.new("Animation", humanoid)
			Animation.AnimationId = "rbxassetid://8725074606"
			local animator = humanoid:FindFirstChildOfClass("Animator")
			if animator then
				local animationTrack = animator:LoadAnimation(humanoid.Animation)
				animationTrack:Play()
				return animationTrack
			end
		end
	end
end)

I am not getting any errors when running the code, I recommend try running it again

1 Like

It’s not the code I had before, but it still doesn’t work, I get this occasionally:

Model:SetPrimaryPartCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this. - Client - LocalScript:28

Remember to set the model’s PrimaryPart property again. (Set it the part called “Top”)

That fixed it. Now do I make a IDLE animation or something? It still didn’t fix the weird reload bug, though.

Well, show a video of what the code is doing currently.

I don’t think the animation even plays? Just hand movement:
robloxapp-20220205-0927021.wmv (3.5 MB)

I think that has something to do with the animation you are using.

1 Like

This is they key sequence things. It doesn’t appear in the animator, either:
image

robloxapp-20220205-0933111.wmv (231.9 KB)

I am not exactly sure then. I will have to look into it a bit later.

1 Like

So what do I do now? Do I just make a IDLE Animation then or something?

I guess it can definitely help

Also, the gridOffset table lets you move the position of the gun in the player’s hands.

(So it does not stay inside their arm).

There should be a property called Loop on the animation

1 Like

How do I loop animations? Is it a hidden property of something?