How do I transfer raycastresults by using remote events?

I am trying to make a raycasting gun system that does the raycasting on the client side, but whenever i try to transfer raycastresult.position and raycastresult.normal for bullet holes using remote events from client to server, it just doesn’t work.

Code to transfer:

script.Parent.RayCastEvent2:FireServer(CFrame.new(pos,pos+normal), Result)

Did you get some of the parameter(cframe or result), or you get nothing?

Everytime I try getting the CFrame parameter from the server side after firing the remote event, there’s an error in the output called [CFrame is not a valid member of Player “Players.bandy512”].

This is the part of the script trying to get the parameters transferred from the client side.

script.Parent.RayCastEvent2.OnServerEvent:Connect(function(cframe, part)
	local hole = game.ReplicatedStorage:FindFirstChild("bullethole")
	hole.CFrame = cframe.CFrame

The first parameter by defaut is a player:

script.Parent.RayCastEvent2.OnServerEvent:Connect(function(player, cframe, part)

2 Likes

If you want all the raycast data, just send over a table of all the data.

local tbl = {Result.Instance, Result.Position, Raycast.Material, Raycast.Normal}
script.Parent.RayCastEvent2:FireServer(CFrame.new(pos,pos+normal), tbl)
2 Likes

Kinda silly that it wouldn’t be able to be passed normally by just passing the table it returns in the first place, is there another way to do this?

Edit: I just did it through a table with the info I needed, still kinda silly

1 Like