Unable to cast value to objects

So, I’m following this tutorial from 2020 on how to make a gun for my game and I came across this issue I can’t figure out…

script.Parent.Fire.OnServerEvent:Connect(function(player, mousePos)
	local raycastParams = RaycastParams.new()
	raycastParams.FilterDescendantsInstances = (player.Character) -- Where the problem is
	raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	
	local raycastResult = workspace:Raycast(script.Parent.Handle.Position,(mousePos - script.Parent.Handle.Position)*300,RaycastParams)
	
	if raycastResult then
		local hitPart = raycastResult.Instance
		local model = hitPart:FindFirstAncestorOfClass("Model")
		if model:FindFirstChild("Humanoid") then
			model.Humanoid.Health -= 30
			end
		end
	end)

That’s the current code I’m using, I’d really appreciate it if someone could figure it out.

Thanks,

– Luke

I think (player.Character) should be a table, so {player.Character}

Now it says “Unable to cast Dictionary to RaycastParams”

image

dont u have to use like Ray.new(orgin,dir)???

use raycastParams with a lowercase “r”

1 Like

Yeah, did it and tried it on an NPC

It worked! :slight_smile: thanks!

1 Like

That’s essentially deprecated, as all it’s useful functions are deprecated themselves.