Kick tool script not working

So i have a tool i want it too kick a player if it hits them

local Tool = script.Parent
local Module = require(Tool:WaitForChild("Setting"))
local can, onAnimation = true, false

if Module.IdleAnimationID ~= nil or Module.DualEnabled then
	local IdleAnim = Instance.new("Animation",Tool)
	IdleAnim.Name = "IdleAnim"
	IdleAnim.AnimationId = "rbxassetid://"..Module.IdleAnimationID
end
if Module.HitAnimationID ~= nil then
	local HitAnim = Instance.new("Animation",Tool)
	HitAnim.Name = "HitAnim"
	HitAnim.AnimationId = "rbxassetid://"..Module.HitAnimationID
end
local Players = game:GetService("Players")
function unEquipItems() script.Parent.Parent = Players:GetPlayerFromCharacter(script.Parent.Parent).Backpack end

script.Damage.OnServerEvent:Connect(function(plr,tipe)
	if tipe then
		if tipe == 0 then
			onAnimation = true
		else
			onAnimation = false
		end
	end
end)
script.Parent.Handle.Touched:Connect(function(hit)
	local Players = game:GetService("Players")
	if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name ~= script.Parent.Parent.Name and hit.Parent.Humanoid.Health > 0 and can and onAnimation then
		can = false 
		hit.Parent.Parent:Kick()

	end
	spawn(function() wait(.5) can = true end)

end)


while wait(.1) do 
	if script.Parent.Parent.Name ~= "Backpack" and script.Parent.Parent:FindFirstChild("Humanoid") and script.Parent.Parent.Humanoid.Sit == true then unEquipItems() end 
end

This is literally referring to the workspace property

Or BodyPart > Character > workspace

You can get the Target Player easily instead by using the GetPlayerFromCharacter function, which returns back the Player Instance you want to search from the Character Model

script.Parent.Handle.Touched:Connect(function(hit)
	local Players = game:GetService("Players")
    local TargetPlayer = Players:GetPlayerFromCharacter(hit.Parent)

	if TargetPlayer then
        TargetPlayer:Kick("You have been hit by a overpowered weapon O_O")
	end
end)
1 Like