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

Why does this code not work and how would i check the players team?

Asked by
Puppynniko 1059 Moderation Voter
3 years ago
01local part = script.Parent
02local Shot = script.Parent.Parent.ShotPart
03local firerate = 0
04local dmg = 100
05local speed = 170
06local range = 1000
07local db = true
08local rep = game.ReplicatedStorage:WaitForChild("TeamEvent")
09--[[local targets = {
10    game.Workspace.Model:GetDescendants():GetDescendants()
11}]]
12local lookvector = part.CFrame.LookVector
13while db == true do
14    local target = nil
15    for i,v in pairs(game.Workspace:getChildren()) do
View all 94 lines...

how do i make it not to shoot team mates instead shoot enemy's rn it wont work and i dont know what to do and if there is a more better way of doing this

01elseif script.Parent.Neutral == false and script.Parent.Cap.Value == BrickColor.new("Lapis") then
02            local targets = v:FindFirstChild("Pirate")
03            if hum and targets and hum.Health > 0 then
04                if (targets.Position - Shot.Position).Magnitude < range then
05                    local ray = Ray.new(Shot.Position,(targets.Position - Shot.Position).Unit * range)
06                    local hit, Pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, {Shot, part})
07                    if hit == targets then
08                    target = targets
09                    db = false
10                    else
11                    print("Pirate")
12                    end
13                end
14            end

Answer this question