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

Kick on hit script problem?

Asked by 9 years ago

Ok This is a part of my script it suppose to kick players when they got head shot. but something seems to be a prob.

if Hit and Hit.Parent:FindFirstChild("Humanoid") then
        local Hit_Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
        if Settings.AntiTK and not Hit_Player.Neutral and Hit_Player.TeamColor == Player.TeamColor then
            return
        end
        local Humanoid = Hit.Parent.Humanoid
        local c = Instance.new("ObjectValue")
        c.Name = "creator"
        c.Value = Player
        game.Debris:AddItem(c, 3)
        c.Parent = Humanoid
        if Hit.Name == "Head" then
            Humanoid.remove()
            else
            Humanoid.Health = Humanoid.Health - math.random(Settings.Damage[1], Settings.Damage[2])
        end
0
What's the problem exactly? Are there any errors shown in the output? Spongocardo 1991 — 9y
0
He says he wants it to kick players when they get a headshot, but there's nothing about kicking players. Problem, incorrect title, or just plain stupidity? bobafett3544 198 — 9y

2 answers

Log in to vote
0
Answered by
Relatch 550 Moderation Voter
9 years ago
if Hit and Hit.Parent:FindFirstChild("Humanoid") then
    local Hit_Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
    if Settings.AntiTK and not Hit_Player.Neutral and Hit_Player.TeamColor == Player.TeamColor then
        return
    end
    local Humanoid = Hit.Parent.Humanoid

    local c = Instance.new("ObjectValue")
    c.Name = "creator"
    c.Value = Player
    game.Debris:AddItem(c, 3)
    c.Parent = Humanoid

    if hit.Parent.Name == "Head" then
        Humanoid:Destroy()
    else
        Humanoid.Health = Humanoid.Health - math.random(Settings.Damage[1], Settings.Damage[2])
    end
end
0
well actually this script broke my entire script but from ur presented answer i found my own answer ty :D Revenant101 25 — 9y
0
Sorry. :/ Relatch 550 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

You Could Add A Value To the Sepperate teams, then when the part is hit check for that value then you could do

 if hit.Parent.Name == "Head" then
hit.Parent.Parent:Destroy()

Hope this helps!~

Answer this question