i tried taking a damage script and tried to edit it so instead of taking damage,you get kicked, i've been trying alot to fix this error how i fix it?
local lleg = script.Parent:FindFirstChild("Torso")
local rleg = script.Parent:FindFirstChild("Head")
function findNearestTorso(pos)
local list = game.Workspace:children()
local torso = nil
local dist = 1000
local temp = nil
local human = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
if (temp ~= nil) and (human ~= nil) and (human:remove()) then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
return torso
end
function onTouch(hit)
game.Players:FindFirstChild(hit.Parent.Name) ~= nil then ----the error gets here
human = game.Players:FindFirstChild(hit.Parent.Name)
human:Kick("kick")
end
end
script.Parent.Touched:Connect(onTouch)
lleg.Touched:connect(Hit)
rleg.Touched:connect(Hit)

2 comments
This Script is horribly wrong, please explain what you're trying to do, so I can provide you with something functional
he forgot the if on line 26