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

Kick a player depending on a specific amount of TKs (team kills)?

If anyone knows any leads, videos, or articles that could help me I would really appreciate if you could direct me towards them. Any help is appreciated and thank you.

3 answers

You would have to count the kills as a number value, variable or something. Then when it passes a set amount you kick them with:

player:Kick("Text here if you want to")

It's hard to tell you exactly what to do, as you have not given us any scripts. Do your game use any weapons? If your game has like guns or something you could check when the gun kills someone if it's a team member, if it is you raise the value.

This is just a very crude way of putting it but here we go:

--If you want to access the player, use a local script
local kills = 0
local plr = game.Players.LocalPlayer

repeat wait() until kills > 5
if kills > 5 then
	plr:Kick("Too many kills")
end

I would save TK's as another variable, and if that variable exceeds the limit, then

player:Kick("Too many teamkills!")

If you're making say a melee weapon like a knife then you could;

local tool = script.Parent
local myPlr = game.Players:GetPlayerFromCharacter(tool.Parent)
local TKs = 0
Handle.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid) and attacking then
		local char = hit.Parent
		local player = game.Players:GetPlayerFromCharacter(char)
		hit.Parent.Humanoid:TakeDamage(damage here) --Change damage here to a number
		if hit.Parent.Humanoid.Health = 0 and myPlr.Team == player.Team then
			TKs = TKs + 1
			if TKs >= teamkill_limit then --Change teamkill_limit to a number
				myPlr:Kick("Too many teamkils!")

I didn't define teamkill_limit as I don't know what you want it to be, same with 'damage here'

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