So I've got this code here:
wait(10)
game.Players.LocalPlayer:GetMouse().Button1Down:connect(function()
local ray = Ray.new(game.Players.LocalPlayer.Character.Torso.CFrame.p, (game.Players.LocalPlayer:GetMouse().Hit.p - Vector3.new(game.Players.LocalPlayer:GetMouse().Hit.y) - game.Players.LocalPlayer.Character.Torso.CFrame.p).unit*100)
local hit, position = game.Workspace:FindPartOnRay(ray, game.Players.LocalPlayer.Character)
local didithit = hit
if didithit then print(hit.Name)
end
local distance = (position - game.Players.LocalPlayer.Character.Torso.CFrame.p).magnitude
local rayPart = Instance.new("Part", game.Players.LocalPlayer.Character)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.new("Bright red")
rayPart.Transparency = 0.5
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.TopSurface = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.formFactor = Enum.FormFactor.Custom
rayPart.Size = Vector3.new(0.2, 0.2, distance)
rayPart.CFrame = CFrame.new(position, game.Players.LocalPlayer.Character.Torso.CFrame.p) * CFrame.new(0, 0, -distance/2)
game.Debris:AddItem(rayPart, 0.1)
end)
It works perfectly fine as is, I made it with help from the Wiki. But I've got an issue with an edit I want to make with it. When the ray is shot, I'd like it to fire the ray using the X and Z axis, but not the Y Axis. This sounds a little vague, so let me explain.
I've got an Isometic camera (Top Down). When the ray fires, it currently will hit the floor, due to the ray firing exactly where my mouse is pointing to. I'd like it to only fire left, right, forward, and backward. Not up or down. I've toyed with it a bit, but any change I make to the scripts end up breaking it.

4 comments
I'm not really sure exactly what your asking. Are you asking so that the camera only moves in four directions?
No. I'm not asking for anything related to the camera.
I see what you're trying to do... I think that when you're casting the ray, have the Y already set? (If that's even possible?)
So you just want a straight ray, correct?