Bug with laser eye script

I’m making a laser eye script that follows the mouse for a game i’m making. There are 2 problems with it infact. you need the laser eye to go thru the character for it to damage. When you point it at the player it doesnt damage. And the remote function wont update mousevector. Does anyone have any ideas how to fix these problems? If so please tell me. Thanks in advance! :smile:

Server Script: ` game.ReplicatedStorage.Remotes.Lasere.OnServerInvoke = function(player,mousecf,mousevector)
local model = Instance.new(“Model”,workspace)
local thing = Instance.new(“Part”,model)
thing.CanCollide = false
thing.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,2,5)
thing.Anchored = true
thing.BrickColor = BrickColor.new(“Yellow flip/flop”)
thing.Material = “Neon”
local s = Instance.new(“Part”,model)
s.CanCollide = false
s.CFrame = player.Character.Head.CFrame * CFrame.new(0.2,0.4,0)
s.Anchored = true
s.Transparency = 0
s.Size = Vector3.new(1,1,1)

local thing2 = Instance.new("Part",model)
thing2.CanCollide = false
thing2.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,2,5)
thing2.Anchored = true
thing2.BrickColor = BrickColor.new("Yellow flip/flop")
thing2.Material = "Neon"
local s2 = Instance.new("Part",model)
s2.CanCollide = false
s2.CFrame = player.Character.Head.CFrame * CFrame.new(-1,0.4,0)
s2.Anchored = true
s2.Transparency = 1
s2.Size = Vector3.new(1,1,1)
coroutine.resume(coroutine.create(function()
	for _= 1,60 do
		wait()
	print("ratio")
local deb = false
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {player.Character}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
		--[[	local ray = Ray.new(s.Position, f.Position - s.Position)
			local ray2 = Ray.new(s2.Position, f2.Position - s2.Position)
			
			local midpoint = ray.Origin + ray.Direction/2
			local midpoint2 = ray2.Origin + ray2.Direction/2 --]]
--(Vector3.new(mouse.Hit.X,mouse.Hit.Y,mouse.Hit.Z)-(Other Vector3 position)).Magnitude
local rayhit = workspace:Raycast(s.Position,mousevector - s.Position,raycastParams)
local rayhit2 = workspace:Raycast(s2.Position,mousevector - s2.Position,raycastParams)
local distance = (s.Position - mousevector).Magnitude
local distance2 = (s2.Position - mousevector).Magnitude

thing.Size = Vector3.new(0.1, 0.1, distance) 
thing.CFrame = CFrame.lookAt(s.Position,mousevector)*CFrame.new(0, 0, -distance/2)
thing2.Size = Vector3.new(0.1, 0.1, distance2) 
thing2.CFrame = CFrame.lookAt(s2.Position, mousevector)*CFrame.new(0, 0, -distance2/2)
if rayhit then
	local hit = rayhit.Instance
	if hit.Parent:FindFirstChild("Humanoid") then
		deb = true
		local hum = hit.Parent:FindFirstChild("Humanoid")
		hum:TakeDamage(0.2)
		coroutine.resume(coroutine.create(function()
			wait(0.1)
			deb = false
				end))
	end
		end
		
	end

end))
return model

end`

Local Script (only posting a portion of the script, so its easier to find the problem): `if Key.KeyCode == Enum.KeyCode.T then
–local modell = Instance.new(“Model”,workspace)
–mouse.TargetFilter = modell

		local model = game.ReplicatedStorage.Remotes.Lasere:InvokeServer(mouse.Hit.Position,mouse.hit.p)
		mouse.TargetFilter = model
		
	
end`
2 Likes

bumping this, someone help me please