Z3tsa
(Zetsa)
July 21, 2021, 7:24am
#1
I am trying to make a gun point towards the player’s mouse but I can’t find out how to. I have already tried searching other topics but none of them worked.
This is what currently happens: https://gyazo.com/014282bc4123391de127d3747297fb83
Here is the code:
local Character = Player.Character
local ToolHandle = Tool:WaitForChild("Handle")
local MouseLookVector = Mouse.Hit.LookVector
ToolHandle.CFrame = CFrame.new(ToolHandle.CFrame.Position, MouseLookVector)
2 Likes
why do u use lookvector? just use mouse.hit.p if u are using vector3 but if u are using cframe use mouse.hit
2 Likes
Have you tried doing something that was along the lines of this?
It would need tweaked obviously for the ToolHandle, but other than that this will stop your brain hurting from inverse kinematics.
I have made a simple local script for you which makes the player’s head and torso follow the player’s mouse. I’ll have a working example below, the .rbxl file provided, and the code! I hope this helps. If you have any questions feel free to ask me.
Code:
local RunService = game:GetService("RunService")
local Player = game.Players.LocalPlayer
local PlayerMouse = Player:GetMouse()
local Camera = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()
local H…
1 Like
Z3tsa
(Zetsa)
July 21, 2021, 7:46am
#4
For some reason I am getting this error and I can’t fix it.
Here’s is the code:
local ToolHandle = Tool:WaitForChild("Handle")
local HandleOrigin = ToolHandle.C0
It’s either looking for Motor6D or WeldConstraint