Hello, When i try to use mouse.hit it keeps going towards the camera. How would i fix this?
script.Parent.Activated:connect(function() local mouse = game.Players.LocalPlayer:GetMouse() mouse.keyDown:connect(function(key) if key == "i" then local Highlight = Instance.new("Part",workspace) Highlight.Anchored = true Highlight.CanCollide = false Highlight.Size = Vector3.new(2.5,.1,2.5) while wait() do if mouse.hit.p then local Ignore = {script.Parent,game.Players.LocalPlayer.Character} local Ray = Ray.new(script.Parent.Handle.CFrame.p,(mouse.Hit.p - script.Parent.Handle.CFrame.p).Unit*50) local Part,Position = workspace:FindPartOnRayWithIgnoreList(Ray,Ignore,false,true) Highlight.CFrame = CFrame.new(Position.X,Position.Y,Position.Z) end end end end) end)
It's because the ray is hitting Highlight. Add Highlight to the ignore list.
local Ignore = {script.Parent,game.Players.LocalPlayer.Character, Highlight}