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

How to give weapons to certain players? (Solved)

Asked by 10 years ago

I have an event called 'Give Items'. When fired, it activates a script so it chooses random people, and gives them weapons. It only prints who it is.

game.ServerStorage["Give Items"].Event:connect(function()
players = {}
Assassin = ""
Protector = ""

function GetPlayers()
    for i,v in pairs(game.Players:GetChildren()) do
        table.insert(players,v)
    end
end

GetPlayers()

function SelectPlayer()
    local num = math.random(1,#players)
    Assassin = players[num].Name
    print('Assassin is: ' ..Assassin)
end

SelectPlayer()

function SelectPlayer2()
    local num = math.random(1,#players)
    Protector = players[num].Name
    print('Protector is: ' ..Protector)
end

SelectPlayer2()

if Assassin == Protector then
SelectPlayer2()
end


function Sword(player)
    local player = game.Players:FindFirstChild(player)
    local Sword = game.ServerStorage.MidnightSword:clone()
    if player~= nil then
        Sword.Parent=player
    end
end

function Bow(player)
    local player = game.Players:FindFirstChild(player)
    local Bow = game.ServerStorage.DynamicallyLitBow:clone()
    if player~= nil then
        Bow.Parent=player
    end
end

Sword(Assassin)
Bow(Protector)

end)


Also, is there anyway to make it so Assassin cannot ever == Protector?

Answer this question