So I want to make a gun using raycasting, and I got all of the detection and stuff done. But whenever I print the object it hit, it always says baseplate. How do I fix this?

script.Parent.OnServerEvent:Connect(function(plyr,mpos)
	local c = plyr.Character
	local HumRootPart = c.HumanoidRootPart

	--Ray Variables--
	
	
	
	local RayOrigin = HumRootPart.Position	
	
	local RayDirect = mpos-HumRootPart.Position*300
	
	local RayParams = RaycastParams.new()
	RayParams.FilterDescendantsInstances = {HumRootPart.Parent}
	RayParams.FilterType = Enum.RaycastFilterType.Blacklist
	
	local ray = workspace:Raycast(RayOrigin,RayDirect,RayParams)
		
	if ray then
		local hitray = ray.Instance
		print(hitray.Name)
	if hitray.Parent:FindFirstChild("Humanoid") then
			
		hitray.Parent.Humanoid.Health -=20
	end

1 comment

0

idk really how to solve this but i got a tip: do "Humanoid:TakeDamage(20)", it should you from killing players with forcefields