I making a round based game.I make a script on enable and disabling values on the script but It says the output that Player is not a valid member of Players.This is my part of my script that it enable and disabling values.
01 | local plrs = game.Players:GetChildren() |
02 | for i,v in pairs (game.Players:GetPlayers()) do |
03 | local num = math.random( 1 , 10 ) |
04 | plrs [ i ] .Character.Head.CFrame = CFrame.new(workspace.Minigame 1. Spawns [ "Spawn" ..num ] .Position) |
05 | plrs [ i ] .Character.Humanoid.WalkSpeed = 0 |
06 | game.Players.Player.stats.Playing.Value = true |
07 | game.Players.Player.stats.Winners.Value = false |
08 | end |
09 | break |
10 | end |
But why it says on my output that Player is not valid member of players on the lines game.Players.Player.stats.Playing.Value = true game.Players.Player.stats.Winners.Value = false
Hi robloxsario,
1 | game.Players.Player |
01 | local plrs = game.Players:GetChildren() |
02 | for i,v in pairs (game.Players:GetPlayers()) do |
03 | local num = math.random( 1 , 10 ) |
04 | local player = plrs [ i ] — The new variable for the current player it is looping through. |
05 | local char = player.Character — The character of the current player to stop repetition and make things more organized. |
06 | local stats = player:WaitForChild(‘stats’) — A variable for the stats item inside of the player, to help with stopping repetition and making stuff more organized. |
07 | character.Head.CFrame = CFrame.new(workspace.Minigame 1. Spawns [ "Spawn" ..num ] .Position) |
08 | character.Humanoid.WalkSpeed = 0 |
09 | stats:WaitForChild(‘Playing’).Value = true |
10 | stats:WaitForChild(‘Winners’).Value = false |
11 | end |
12 | break |
13 | end |
Thanks,
Best regards,
Idealist Developer