having a problem with raycasting (im pretty new to it lol)
trying to create a raycast that makes a trajectory on the server
when i try to deliver the raycasting result, it passes if rayresult then
however returns nil on the server
am i doing smth wrong?
module script
local head = player.Character.Head.CFrame.LookVector
local mouse = CFrame.new(player.Character.Head.Position, mouse.Hit.Position).LookVector
local difference = (head-mouse)
self.Viewmodel.Gun.PrimaryPart.Muzzle.Flash:Emit(10)
self.Viewmodel.Gun.PrimaryPart.Chamber.Casings:Emit(1)
local raycastParams = RaycastParams.new()
raycastParams.RespectCanCollide = true
raycastParams.FilterDescendantsInstances = {self.Viewmodel:GetChildren(), player.Character}
local rayresult = workspace:Raycast(self.Viewmodel.Gun.PrimaryPart.Muzzle.WorldCFrame.Position, (player:GetMouse().Hit.Position - self.Viewmodel.Gun.PrimaryPart.Muzzle.WorldCFrame.Position).unit * 300, raycastParams)
if rayresult then
remotes.Gunfire:FireServer(self.Tool, rayresult)
player.Character.Humanoid.WalkSpeed = player.PlayerGui["Realism Mod"].Sprint.Settings["Walking speed"].Value
end
server script starting loop
remotes.Gunfire.OnServerEvent:Connect(function(player, tool, raycastResult)