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

A script meant to do something to everyone in a team only does it for one player?

Asked by
zValerian 108
5 years ago

This script is a countdown for when a round begins. At the end of the countdown, it is supposed to give all the players teamed 'Fighters' a sword. However, it only gives it to one player, any ideas why?

wait(5)
sword = game.ServerStorage.Sword:Clone()
for i = 10,0,-1 do
    wait(1.2)
    local text = "Good luck! The round is starting in: " ..i
    game.ReplicatedStorage.cd:FireAllClients(text, i)
    print(i .. "XDXDXD")

    if i == 0 then 
game.Workspace.songg.SoundId = "http://www.roblox.com/asset/?id=1842263532"
game.Workspace.songg:Play()

for i,v in pairs(game.Teams.Fighters:GetPlayers()) do
                sword.Parent = v.Backpack
            end


        game.ServerScriptService.gamecd.Disabled = false
        lol = true
        game.ReplicatedStorage.roundd.Value = game.ReplicatedStorage.roundd.Value + 1
script.Parent.round.Disabled = true
script.Disabled = true
    end
end


This is the part of the script that does the giving:

for i,v in pairs(game.Teams.Fighters:GetPlayers()) do
                sword.Parent = v.Backpack
            end

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
5 years ago

Because you only cloned one sword. You need to clone one for each player.

for i,v in pairs(game.Teams.Fighters:GetPlayers()) do
    local sword = game.ServerStorage.Sword:Clone()
    sword.Parent = v.Backpack
end
Ad

Answer this question