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

How do I make a script that kills others on touch?

Asked by 6 years ago

Hi, I'm making a minigame which is a race to the finish, but due to how I scripted the game it can pick only one winner; the last one standing alive, so I tried multiple ways to make a script that once inserted in a part, will kill all other players except the one which touched it. Can anyone give me a hand? Thanks in advance!

0
use the touched event and the parameter User#23365 30 — 6y
0
winner touches -> loop through players -> kill if not winner Vulkarin 581 — 6y

3 answers

Log in to vote
0
Answered by 6 years ago
game.Workspace.Part.KillEverybodyWhoDidntTouchItAfterTheFirstGuyTouchesIt()
Ad
Log in to vote
0
Answered by
Donut792 216 Moderation Voter
6 years ago

like vulkarin said find name of the person that touches it (winner or exploiter) with something like

game.Workspace.WinPart.Touched:connect(function(hit)
local Winner = hit.Parent.Name -- if not hit.parent then just hit

then go through the playerlist with for loop (im not to good in for loops just yet cut me some slack)

Players = game:GetService("Players")
for i, player in pairs(Players:GetPlayers()) do
   if player.Name = not Winner then
    player.Character.Humanoid.Health = 0 --or breakjoints
end
Log in to vote
0
Answered by 6 years ago
script.Parent.Touched:connect(function(hit)
hit.parent.Head:Destroy()
end)

Hope this helped :D

Answer this question