as the title says, i’m making a laser eye script for a game. For some reason I made it in a local script first cause its a habit I have sometimes. I decided to convert it to the server and It wont work at all. Nothing is being printed to the console.
Heres my script. If anyone has any ideas of what I did wrong please tell me. Thanks in advance!
SERVER:
game.ReplicatedStorage.Remotes.Lasere.OnServerEvent:Connect(function(player,modell,mouse)
local AudioModule = require(game.ReplicatedStorage.AudioModule)
local GroundEFF = require(game.ReplicatedStorage.GroundEffect)
local AnimModule = require(game.ReplicatedStorage.AnimationModule)
local Oof = require(game.ReplicatedStorage.hi)
local char = player.Character
local hrp = char.HumanoidRootPart
local thing = Instance.new("Part",modell)
thing.CanCollide = false
thing.CFrame = hrp.CFrame * CFrame.new(0,2,5)
thing.Anchored = true
thing.BrickColor = BrickColor.new("Yellow flip/flop")
thing.Material = "Neon"
print("oh")
local s = Instance.new("Part",workspace)
s.CanCollide = false
s.CFrame = char.Head.CFrame * CFrame.new(0.2,0.4,0)
s.Anchored = true
s.Transparency = 1
s.Size = Vector3.new(1,1,1)
local f = Instance.new("Part",modell)
f.CanCollide = false
f.CFrame = CFrame.new(mouse)
f.Anchored = true
f.Transparency = 1
f.Name = "What"
f.Size = Vector3.new(1,1,1)
local thing2 = Instance.new("Part",modell)
thing2.CanCollide = false
thing2.CFrame = hrp.CFrame * CFrame.new(0,2,5)
thing2.Anchored = true
thing2.BrickColor = BrickColor.new("Yellow flip/flop")
thing2.Material = "Neon"
local s2 = Instance.new("Part",workspace)
s2.CanCollide = false
s2.CFrame = char.Head.CFrame * CFrame.new(-1,0.4,0)
s2.Anchored = true
s2.Transparency = 1
s2.Size = Vector3.new(1,1,1)
local f2 = Instance.new("Part",modell)
f2.CanCollide = false
f2.CFrame = CFrame.new(mouse)
f2.Anchored = true
f2.Transparency = 1
f2.Size = Vector3.new(1,1,1)
local att = Instance.new("Attachment",f)
local particle = game.ReplicatedStorage.laserparticle:Clone()
particle.Parent = att
local deb = false
coroutine.resume(coroutine.create(function()
while true do
f.CFrame = CFrame.new(mouse.X,mouse.Y,mouse.Z)
f2.CFrame = CFrame.new(mouse.X,mouse.Y,mouse.Z)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {char}
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 --]]
local rayhit = workspace:Raycast(s.Position,(f.Position - s.Position) * 1000,raycastParams)
local rayhit2 = workspace:Raycast(s2.Position,(f2.Position - s2.Position) * 1000,raycastParams)
local distance = (rayhit.Position - s.Position).Magnitude
local direction = (rayhit.Position - s.Position)
local distance2 = (rayhit2.Position - s2.Position).Magnitude
local direction2 = (rayhit2.Position - s2.Position)
local MiddlePoint = s.Position + direction/2
local MiddlePoint2 = s2.Position + direction2/2
thing.CFrame = CFrame.new(MiddlePoint,rayhit.Position)
thing.Size = Vector3.new(0.1, 0.1, distance)
thing2.CFrame = CFrame.new(MiddlePoint2,rayhit2.Position)
thing2.Size = Vector3.new(0.1, 0.1, distance2)
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
wait()
end
end))
end)
CLIENT:
local modell = Instance.new("Model",workspace)
mouse.TargetFilter = modell
game.ReplicatedStorage.Remotes.Lasere:FireServer(modell,mouse.Hit.Position)