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.
local plrs = game.Players:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do local num = math.random(1,10) plrs[i].Character.Head.CFrame = CFrame.new(workspace.Minigame1.Spawns["Spawn"..num].Position) plrs[i].Character.Humanoid.WalkSpeed = 0 game.Players.Player.stats.Playing.Value = true game.Players.Player.stats.Winners.Value = false end break 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,
game.Players.Player
local plrs = game.Players:GetChildren() for i,v in pairs(game.Players:GetPlayers()) do local num = math.random(1,10) local player = plrs[i] — The new variable for the current player it is looping through. local char = player.Character — The character of the current player to stop repetition and make things more organized. 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. character.Head.CFrame = CFrame.new(workspace.Minigame1.Spawns["Spawn"..num].Position) character.Humanoid.WalkSpeed = 0 stats:WaitForChild(‘Playing’).Value = true stats:WaitForChild(‘Winners’).Value = false end break end
Thanks, Best regards, Idealist Developer