Problem with detecting player

  1. What do you want to achieve? Keep it simple and clear!
    I want to detect if the hithumanoid is a player or not. (I have made the script)

  2. What is the issue? Include screenshots / videos if possible!
    The issue is that my script isn’t working. I tried it in play test.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I don’t think there is a solution out there for my problem.

-- Services
local Players = game:GetService("Players")

-- Tool
local Tool = script.Parent.Parent

-- Sound Folder
local SoundParent = Tool.Handle

-- Modules
local ClientCast = require(game.ReplicatedStorage.ASCS.ClientCast)
local Config = require(Tool.Modules.Config)

-- ClientCast
local clientCasterParams = RaycastParams.new()
clientCasterParams.FilterType = Enum.RaycastFilterType.Blacklist
clientCasterParams.IgnoreWater = true
clientCasterParams.FilterDescendantsInstances = {Tool.Parent.Parent.Character}

local Caster = ClientCast.new(Tool.Handle, clientCasterParams)

local db = {}

Tool.Remotes.ClientCast.OnServerEvent:Connect(function(plr, length, cooldown)
	local event = Caster.HumanoidCollided:Connect(function(result, hithumanoid)
		if Config.CanHitPlayers and not Config.CanHitNPCs then
			if hithumanoid.Parent == Players:GetPlayerFromCharacter(hithumanoid.Parent) then
				if db[hithumanoid] then return end

				db[hithumanoid] = true

				hithumanoid:TakeDamage(Config.Damage)
				SoundParent:WaitForChild("Hit"):Play()
				hithumanoid.WalkSpeed -= hithumanoid.WalkSpeed
				hithumanoid.JumpPower -= hithumanoid.JumpPower

				wait(.2)
				hithumanoid.WalkSpeed = Config.WalkSpeed
				hithumanoid.JumpPower = Config.JumpPower
				db[hithumanoid] = false
			else
				return
			end
		elseif Config.CanHitPlayers and Config.CanHitNPCs then
			if db[hithumanoid] then return end

			db[hithumanoid] = true

			hithumanoid:TakeDamage(Config.Damage)
			SoundParent:WaitForChild("Hit"):Play()
			hithumanoid.WalkSpeed -= hithumanoid.WalkSpeed
			hithumanoid.JumpPower -= hithumanoid.JumpPower

			wait(.2)
			hithumanoid.WalkSpeed = Config.WalkSpeed
			hithumanoid.JumpPower = Config.JumpPower
			db[hithumanoid] = false
		elseif not Config.CanHitPlayers and Config.CanHitNPCs then
			if hithumanoid.Parent ~= Players:GetPlayerFromCharacter(hithumanoid.Parent) then
				if db[hithumanoid] then return end

				db[hithumanoid] = true

				hithumanoid:TakeDamage(Config.Damage)
				SoundParent:WaitForChild("Hit"):Play()
				hithumanoid.WalkSpeed -= hithumanoid.WalkSpeed
				hithumanoid.JumpPower -= hithumanoid.JumpPower

				wait(.2)
				hithumanoid.WalkSpeed = Config.WalkSpeed
				hithumanoid.JumpPower = Config.JumpPower
				db[hithumanoid] = false
			else
				return
			end
		elseif not Config.CanHitPlayers and not Config.CanHitNPCs then
			return
		end
	end)
	
	Caster:Start()
	
	task.wait(math.max(length, cooldown))
	Caster:Stop()
	event:Disconnect()
end)