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

How to script a npc that does not shoot your team only the enemy?

Asked by 9 years ago

my script:

001local figure = script.Parent
002local Tool = script.Parent.PaintballGun
003local reload = .5
004 
005function modechange()
006    local mode = figure.mode
007    if mode.Value == 1 then reload = .5
008    elseif mode.Value == 2 then reload = 5
009    elseif mode.Value == 3 then reload = 1.5
010    elseif mode.Value == 4 then reload = 10 end
011end
012 
013function findNearestTorso()
014    local targetTorso = nil
015    local distance = 500
View all 131 lines...

i want to make it so it shoots enemy team only not any player. so it does not shoot its own team mate it only shoots at enemy.

0
You'll need to make an "if" statement to check the player's TeamColor before firing. shayner32 478 — 9y
0
can you plz fix your formatting koolkid8099 705 — 9y
0
Edited to add code formatting BlueTaslem 18071 — 9y
1
^^^ epiclightining 0 — 6y

1 answer

Log in to vote
0
Answered by
Slatryte 104
5 years ago

I believe I know how to fix this...

Basically, create teams and make a separate that randomly chooses teams or they can choose their team. You must also choose team colours as these are important to the script.

Then, use this script:

01local figure = script.Parent
02local Tool = script.Parent.PaintballGun
03local reload = .5
04 
05function modechange()
06    local mode = figure.mode
07    if mode.Value == 1 then reload = .5
08    elseif mode.Value == 2 then reload = 5
09    elseif mode.Value == 3 then reload = 1.5
10    elseif mode.Value == 4 then reload = 10 end
11end
12local player = game.Players.LocalPlayer
13if player.TeamColor == 'TeamColour' then
14function findNearestTorso()
15    local targetTorso = nil
16    local distance = 500
17end
0
Sorry, uh- just continue your script before adding the end. Slatryte 104 — 5y
Ad

Answer this question