Returning ray with remote function

When i return a ray it via remote function it always returns nil to the server
is there a work around this? or no i’m trying to keep everything optimized and doing it on the server seems weird
local script-
script.Parent:WaitForChild(“Raycast”).OnClientInvoke = function(char)

local pos = game.Players.LocalPlayer:GetMouse().Hit.Position
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Whitelist
params.FilterDescendantsInstances = {game.Workspace:WaitForChild(“Map”),game.Workspace:WaitForChild(“Players”)}

return workspace:Raycast(char:WaitForChild("ArtillerHandle").Position, (char.ArtillerHandle.Fire.WorldPosition - pos).unit * 100, params)

end

it’s a tool and char is actually the character

forgot to add the server script- server script is suppost to be below end and the “it’s a tool and the car is actually the character” should be ignored

local hit = script.Parent:WaitForChild("Raycast"):InvokeClient(game.Players:GetPlayerFromCharacter(char), char)

i’ll see if returning ray.instance works

it works i’m stupid all i had to do was return ray.instance instead

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.