Hello, today I will show you how to make the tool follow the camera with a hold animation.
1. The first thing you need to do is create a tool!
You can put the handle where you want!
You also need to weld the handle with the rest of the parts
For welding you need a plugin - Constraint Editor - Roblox
First select the handle and then all the parts in the FlashlightModel and press new Weld
You can also use the Tool Grip plugin for a proper grip - Tool Grip Editor (Rojo Version) - Roblox (free version)
2. Now you need to make the grip animation!
Create a Dummy
After creating a Dummy, make it an animation!
Also you need to select in Set Animation Priority → Idle
Then you must publish your animation
And copy id
3.Create a local script in the tool
After you have created a local script, you need to write:
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"); local handler = nil 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=YOUR ANIMATION ID HERE" handler = RunService.Stepped:Connect(function() -- update direction to camera's look vector local direction = game.Workspace.CurrentCamera.CFrame.lookVector * 500; -- 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.5, 0, 0); end) end) script.Parent.Unequipped:Connect(function() if Tool then animScript:WaitForChild("toolnone"):WaitForChild("ToolNoneAnim") animScript.toolnone.ToolNoneAnim.AnimationId = "https://www.roblox.com/asset/?id=YOUR ANIMATION ID HERE" handler:Disconnect() end end)
4. Congratulations! You have made your flashlight!
If you have any errors write me and I will help you!
If there is good activity under this post, then I will show how to make a light on click
(My English is bad)