Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Kick on hit script problem?

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

2 comments

0

What's the problem exactly? Are there any errors shown in the output?

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?

2 answers

✓ Accepted answer
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

2 comments

0

well actually this script broke my entire script but from ur presented answer i found my own answer ty :D

0

Sorry. :/

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!~

This discussion is preserved as it was. New answers, comments, and votes are closed.