Script help it is not working as intended

local Tool = nil
local animScript = nil
local Players = game:GetService(“Players”);
local RunService = game:GetService(“RunService”);
wait();

— Declarations —
local Player = Players.LocalPlayer;
local Character = Player.Character or Player.CharacterAdded:Wait();

local Mouse = Player:GetMouse();

— Character —
local RightUpperArm = Character:WaitForChild(“RightUpperArm”);
local RightShoulder = RightUpperArm:WaitForChild(“RightShoulder”);
local HumanoidRootPart = Character:WaitForChild(“HumanoidRootPart”);
script.Parent.Equipped:Connect(function()
Tool = script.Parent
animScript = Tool.Parent:WaitForChild(“Animate”)
animScript:WaitForChild(“toolnone”):WaitForChild(“ToolNoneAnim”)
animScript.toolnone.ToolNoneAnim.AnimationId = “https://www.roblox.com/asset/?id=12692036080
RunService.Stepped:Connect(function()
local hit = Mouse.Hit;

	-- add the lookVector * 5000 to the hit.p to make the point more "dramatic" (remove it and you'll see why I did this)
	local direction = hit.p + (hit.lookVector * 5000);

	-- get the rotation offset (so the arm points correctly depending on your rotation)
	local rootCFrame = HumanoidRootPart.CFrame;
	local rotationOffset = (rootCFrame - rootCFrame.p):inverse();

	-- since CFrames are relative, put the rotationOffset first, and then multiple by the point CFrame, and then multiple by the CFrame.Angles so the arm points in the right direction
	RightShoulder.Transform = rotationOffset * CFrame.new(Vector3.new(0, 0, 0), direction) * CFrame.Angles(math.pi / 2, 0, 0);
end)

end)
script.Parent.Unequipped:Connect(function()
animScript:WaitForChild(“toolnone”):WaitForChild(“ToolNoneAnim”)
animScript.toolnone.ToolNoneAnim.AnimationId = “https://www.roblox.com/asset/?id=12692036080
– reset the arm position by setting the Transform to the default value
RightShoulder.Transform = CFrame.new(Vector3.new(0, 0, 0))
end)

1 Like

The problem is the animation in the tool doesn’t work. The tool is not affected at all by this script bro.

1 Like

Replace that with this:

animScript.toolnone.ToolNoneAnim.AnimationId = "rbxassetid://12692036080"
1 Like