RaycastParams FilterDescendantsInstances Error

Hello Everyone.

Following AlvinBlox’s tutorial on Make a GUN in Roblox in 10 minutes - YouTube I keep getting the error:

19:16:44.166 Unable to cast value to Objects - Server - Server:4

This is my current code exactly like the code in the video:

script.Parent.Fire.OnServerEvent:Connect(function(player, mousePos)
	
	local RayCastParams = RaycastParams.new()
	RayCastParams.FilterDescendantsInstances = (player.Character)
	RayCastParams.FilterType = Enum.RaycastFilterType.Blacklist
	
	local RayCastResults = workspace:Raycast(script.Parent.Handle.Position, (mousePos - script.Parent.Handle.Position * 300), RayCastParams)
	
	if RayCastResults then
		local HitPart = RayCastResults.Instance
		local Model = HitPart.FindFirstAncestorOfClass("Model")
		
		if Model then
			if Model.FindFirstChild("Humanoid") then
				Model.Humanoid.Health -= 30
			end
		end
	end
end)

Line 4 is this line, which if your looking for the API reference for is here: RaycastParams

RayCastParams.FilterDescendantsInstances = (player.Character)

Any help would be appreciated.
Thanks in advance.
ICrann

You must use curly brackets not regular brackets

RayCastParams.FilterDescendantsInstances = {player.Character}
1 Like

Thank you very much. I had the video on a low resolution(as you can see in the picture) and it was unclear and there for I just thought it was an ordinary bracket, but I should have know since it was an array.

1 Like