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

Assigning Weapons to a certain team?

Asked by 4 years ago

I'm trying to make a script that whenever a player joins, it would loop the players and see if they are on Team1 or Team2. Then give the appropriate weapon to it. The script is a Module Script.

The problem is it does not assign it a Tool even though it has no errors, I've tried print debugging and it exactly locates to where it assigns the weapon.

All I need to know is why this is not working, not asking for anything other than that.

Thanks for viewing this!

function module:AssignTeamWeapons()
    local players = game.Players:GetPlayers()
    if #players == 1 then
        return nil
    end
    for i,v in pairs(players) do
        print("Looping through player"..v.Name)
        if v.Team == game.Teams.Team1 then
            local clone = game.ServerStorage.TeamWeapons.Pistol:Clone()
            clone.Parent = v:WaitForChild("Backpack")
            print("Gave Pistol to Survivor")
        elseif v.Team == game.Teams.Team2 then
            local clone = game.ServerStorage.TeamWeapons.ZombieTool:Clone()
            clone.Parent = v:WaitForChild("Backpack")
            print("Gave ZombieTool to Zombie")
        end
    end
end

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Do you ever callback that function with a server script?

Nvm found ur problem

"if #player == 1 then return nil end"

most likely ur testing this out solo

0
I'm not sure what a "callback" is but I don't playtest solo I do a server test instead. Usually I server test with three players. All the print statements do print but the main problem is they are not giving the tool. Thanks for viewing. 123nabilben123 499 — 4y
Ad

Answer this question