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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
Lucke0051 165
5 years ago
Edited 5 years ago

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:

1player: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.

Ad
Log in to vote
0
Answered by 5 years ago

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

1--If you want to access the player, use a local script
2local kills = 0
3local plr = game.Players.LocalPlayer
4 
5repeat wait() until kills > 5
6if kills > 5 then
7    plr:Kick("Too many kills")
8end
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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

1player:Kick("Too many teamkills!")

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

01local tool = script.Parent
02local myPlr = game.Players:GetPlayerFromCharacter(tool.Parent)
03local TKs = 0
04Handle.Touched:Connect(function(hit)
05    if hit.Parent:FindFirstChild("Humanoid) and attacking then
06        local char = hit.Parent
07        local player = game.Players:GetPlayerFromCharacter(char)
08        hit.Parent.Humanoid:TakeDamage(damage here) --Change damage here to a number
09        if hit.Parent.Humanoid.Health = 0 and myPlr.Team == player.Team then
10            TKs = TKs + 1
11            if TKs >= teamkill_limit then --Change teamkill_limit to a number
12                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'

Answer this question