Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script does not kill at all on touched?

Asked by 4 years ago

Hi, I have a problem where my script just will not kill at all for some reason. There aren't any errors, it registers .Touched, it just will not kill!

Here's the code:

Humanoid = script.Parent:WaitForChild("Humanoid")
local debounce = false

function award(plr)
    if not game.BadgeService:UserHasBadgeAsync(plr.UserId, 2124571974) then
        game.BadgeService:AwardBadge(plr.UserId, 2124571974)
    end
end

function onTouch(hit)
    print(hit)
    if debounce ~= true then
        debounce = true
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        local currentplayer = game.Players:GetPlayerFromCharacter(script.Parent)
        print(player)
        print(currentplayer)
        if player and currentplayer then
            if hit.Parent.ClassName == "Tool" or hit.Parent.Name == "Handle" then
                currentplayer.Character:BreakJoints()
            end
            if currentplayer.TeamColor == BrickColor.new("Really red") then
            if player.UserId == 111255307 then
                award(currentplayer)
            elseif player.UserId == 424716966 then
                award(currentplayer)
            elseif player.UserId == 109352342 then
                award(currentplayer)
        end
    end
end
    end
    wait(2)
    debounce = false
end

if Humanoid.RigType == Enum.HumanoidRigType.R6 then
    script.Parent:WaitForChild("Torso").Touched:Connect(onTouch)
else
    script.Parent:WaitForChild("UpperTorso").Touched:Connect(onTouch)
end

while true do
    wait(0.1)
    Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end

The most important part is this:

if hit.Parent.ClassName == "Tool" or hit.Parent.Name == "Handle" then
    currentplayer.Character:BreakJoints()
end

I have no idea why this doesn't work. Please help!

0
What about making class name like humanoid maybe?? sean_thecoolman 189 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

If everything else in your script is all good then this should work.

Try doing...

currentplayer.Character.Humanoid.Health = 0
0
If that doesnt work its most likely an issue with the other parts of the script. THUNDER_WOW 203 — 4y
0
yeah it doesn't work for some reason Dax009YT 6 — 4y
0
Id suggest rescripting it, and test it after like every line of code to make sure it works. THUNDER_WOW 203 — 4y
0
Id suggest using humanoid:TakeDamage(100) instead of that Leamir 3138 — 4y
0
I dont think itd make a difference since the rest of his script is what the problem is. THUNDER_WOW 203 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I just decided to rescript and change my badge. Thanks for the help!

Answer this question