Is there any way I could fix a client sided raycast?

I am trying to process a shot through a RemoteEvent with a client sided raycast function

It sends a print to the server printing the name of what it’s hit but it just prints my name. How do I fix this?

Client Script:

local function raycast()
	local ignore = {character, Player}
	local FromP = script.Parent.Handle.CFrame.Position
	local ToP = mouse.Hit.Position
	local RayCast = Ray.new(FromP, (ToP-FromP).unit*module.Range)
	local part, Position = game.Workspace:FindPartOnRayWithIgnoreList(RayCast, ignore, false, true)
	if part then
		local Hum = part.Parent:FindFirstChild("Humanoid")
		if Hum then
			script.ProcessShot:FireServer(part)
		end
	end
end

Server Script:

script.Parent.main.ProcessShot.OnServerEvent:Connect(function(part)
	print(part)
end)
1 Like

The first parameter of OnServerEvent is always the player that fired the remote event,
so your script should be

script.Parent.main.ProcessShot.OnServerEvent:Connect(function(plr,part)
	print(part)
end)

No dice. It didn’t work must be my code then

Woops nevermind. You didn’t mean on both sides! It works now

1 Like