You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I want to shoot a raycast to the player’s mouse -
What is the issue?
It looks as if it thinks the hit is a Vector3 -
What solutions have you tried so far?
I tried removing the.Position
after the hit but it said Unit is not a valid member of CFrame
Here is my code
local function castRay(hit)
local orgin = script.Parent.Handle.Position
local Stop = (hit.Position - orgin).Unit * 500
local result = workspace:Raycast(orgin, Stop, params)
if result then
local target = result.Instance
if target.Parent then
local position = result.Position
return castRay(position)
end
end
end
script.Parent.Shoot.OnServerEvent:Connect(function(player, Hit)
local Attachment0 = Instance.new("Attachment")
Attachment0.Parent = Target
Attachment0.Position = castRay(Hit)
end
If you know how to fix this please let me know!