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

Setting Players' Name Inside a Value while Players are in a Specific Team?

Asked by 7 years ago
Edited 7 years ago

Basically what I'm trying to do is that if players are on a team, I want them to have their own individual stringvalue. These values are in ServerStorage.

01for i, v in pairs(game.Players:GetPlayers()) do
02        local hometeam = game.Teams.Home
03        local awayteam = game.Teams.Away
04        local homeplayers1 = hometeam:GetPlayers()
05        local awayplayers1 = awayteam:GetPlayers()
06        if v.Team == hometeam then
07            local C1 = homeplayers1[math.random(1, #homeplayers1)]
08            local C2 = homeplayers1[math.random(1, #homeplayers1)]
09            local C3 = homeplayers1[math.random(1, #homeplayers1)]
10            local C4 = homeplayers1[math.random(1, #homeplayers1)]
11            local P1 = HomePlayers:WaitForChild("Player1")
12            local P2 = HomePlayers:WaitForChild("Player2")         
13            local P3 = HomePlayers:WaitForChild("Player3")
14            local P4 = HomePlayers:WaitForChild("Player4")
15            if #homeplayers1 > 0 then
View all 57 lines...

Thanks,

LukeGabrieI

[Apparently this script is passed, I haven't gotten any errors, but it doesn't work.]

3 answers

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago
01-- // SERVICES
02local Players = game:GetService('Players')
03local Teams = game:GetService('Teams')
04 
05-- // CONSTANTS
06local Home = Teams:WaitForChild('Home')
07local Away= Teams:WaitForChild('Away')
08 
09-- // VARIABLES
10local HomeTeam = {}
11local AwayTeam = {}
12 
13local HomePlayerTP = workspace:WaitForChild('RedPlayerTP')
14local AwayPlayerTP = workspace:WaitForChild('BluePlayerTP')
15 
View all 67 lines...
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

if game.Players.LocalPlayer.Team then game.Players.LocalPlayer.Character.Parent.Parent.ServerStorage.StringValue:Clone().Parent = game.Players.LocalPlayer end

0
*StringValue:Clone().Parent = DoYouKnowHowToRead -13 — 7y
0
this wouldn't work since I'm trying to accomplish something else after LukeGabrieI 73 — 7y
0
I'm also using filtering Enabled lol, so anything locally won't be cloned LukeGabrieI 73 — 7y
Log in to vote
0
Answered by 7 years ago
1for _,p in pairs(game.Players:GetPlayers()) do
2    local sv = Instance.new("StringValue")
3    sv.Name = "PlayerName"
4    sv.Parent = p
5    sv.Value = p.Name
6end

Answer this question