So. I'm trying to make a grappling hook. Here's my code.
It's in a local script.
local p = game.Players.LocalPlayer
repeat wait() until p.Character
local c = p.Character
local m = p:GetMouse()
m.Button1Down:Connect(function()
--mouse hit position and making a ray so i can make a rope afterwards
local hit = m.Hit.p
local ray = Ray.new(c.RightHand.Position - hit.unit * 300)
--self-explanatory
local part, position = workspace:FindPartOnRay(ray)
--testing where the mouse hit is
local d = Instance.new("Part", workspace)
d.Anchored = true
d.Position = hit
print(part)
end)
Whenever I test this, I click on a block and it returns nothing. The 'd' part locates itself on the block. FindPartOnRay just isn't working for me.
Any help is appreciated, thanks.
EDIT: It is working. When the ray decides to work and actually point where my cursor is pointing. WHY IN ALL OF HELL WOULD IT NOT POINT WHERE MY CURSOR IS?

1 comment
ok