Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Services ---
- 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");
- --- Execution ---
- 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)
Advertisement
Comments
-
- The localscript works even when my tool is disabled. Can you make another version with this fix?
-
- Hello! All you would need to do is add an if statement that checks if the tool is currently Enabled or not :)
Add Comment
Please, Sign In to add comment