Hello, I want an instance ; a part , to face the mouse once a tool is activated. I have tried many trigonometric functions but it is still not pointing towards my mouse once it is fired.It is a simple script because I am new to RbxLua. I have already searched in the forums , on the roblox wiki and Google'd the issue , but no result till now.
Tool.Activated:connect(function()
local function weld(w)
local We = Instance.new("Weld",chr.UpperTorso)
We.Part1 = chr.UpperTorso
We.Part0 = w
We.C1 = chr.UpperTorso.CFrame:inverse()
We.C0 = w.CFrame * CFrame.new(0,0,0)
end
local x = Instance.new("Part", workspace)
x.Shape = "Cylinder"
x.BrickColor = BrickColor.Random()
x.CanCollide = true
local bg = Instance.new("BodyGyro",x)
bg.MaxTorque = Vector3.new(math.huge,math.huge,math.huge)
bg.P = 10000
local bp = Instance.new("BodyPosition", x)
bp.Position = mouse.Hit.p
x.CFrame = CFrame.new(x.CFrame.p , mouse.Hit.p)
for i = 1 , 200 do
wait()
x.Transparency = x.Transparency + 0.0005
end
weld(x)
d:AddItem(x, 10)
end)
Thank you for your time. P.S : Runs in a local script, no errors , FilteringEnabled is OFF.

1 comment
Issue is fixed with raycasting. Source : Roblox Wiki