I have a script that goes into a part that detects players touching the part. What it does is wait till 1 person walks over the part and the part disappears. Then, if another player falls through that part, it gives the player who first made the part disappear(first touched the part) a kill in leaderstats. The problem is, the code doesn't go into the if statement(line 15) where it asks if the player's head, or torso collided with the part when they fell. I can verify that I've tested that the player does indeed have their head touch the part but it won't do the code inside the if statements so I must presume there's something wrong in how I wrote the condition. Can anyone spot my error? Code is shown below
local Players = game:GetService("Players") local blockOwner = ""--intializes variable LandMine = script.Parent--part local count = 0 function onTouched(hit) if count == 0 then local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) blockOwner=killer(plr) wait(0.05) LandMine.CanCollide = false LandMine.Transparency = 1 count=count+1 else if count>0 then if hit=="Head" or hit=="Handle" or hit=="UpperTorso" then print("Made it past head") local victim = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) print("victim",victim) if victim.died==false then victim.died=true print(victim.died) if blockOwner ~= victim then blockOwner.leaderstats.kills.Value=blockOwner.leaderstats.kills.Value+1 print(blockOwner," killed ",victim) else blockOwner.leaderstats.kills.Value=blockOwner.leaderstats.kills.Value+1 print(blockOwner," killed ",victim) --print("suicide") end elseif victim.died==true then print("duplicate") end end end end end function killer(plr) --// Loop through all existing players and..print everyone's name for _, player in ipairs(Players:GetPlayers()) do if plr == player then blockOwner=plr print(blockOwner) end end return blockOwner end connection = LandMine.Touched:connect(onTouched)