I am trying so hard not to rage quit on this 1 script. Its not working at all. Its not showing any errors either. Is it because I didnt add a leaderbaord to keep track of the score? Idk anymore... NOTHING WORKS....
script :
game.Players.PlayerAdded:connect(function(Player) Player.CharacterAdded:connect(function(Char) Char:WaitForChild("Humanoid").Died:connect(function() if Player.TeamColor == BrickColor.new("Camo") then game.Teams.Sentinel.Score = game.Teams.Sentinel.Score + 1 script.Parent.Text = game.Teams.Sentinel.Score elseif Player.TeamColor == BrickColor.new("Bright red") then --What i've done is, what if the other team kills the other person? This would give them a score as well. game.Teams.Atlas.Score = game.Teams.Atlas.Score + 1 script.Parent.Parent.Atlas.Text = game.Teams.Atlas.Score end end) end) end)
--I made another script because of the possible error I could have made, but it still doesn't work. -- Perci said something about the score value and stuff so I gave it a shot. But it doesn't work. game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = player local Score = Instance.new("IntValue") --We create a new IntValue Score.Name = "Score" --this is the name you want the leader-stat to be when it shows up in-game. Score.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later) Score.Parent = leaderstats -- Set the money object as a child of the leaderstats object. end)
I see a few problems with this script, and I will attempt to fix them
game.Players.PlayerAdded:connect(function(Player) --good Player.CharacterAdded:connect(function(Char) --good Char:WaitForChild("Humanoid").Died:connect(function()--See comment 1 if Player.TeamColor == BrickColor.new("Camo") then --good unless "Camo" doesn't exist game.Teams.Sentinel.Score = game.Teams.Sentinel.Score + 1 --See Comment 2 script.Parent.Text = game.Teams.Sentinel.Score --See comment 2 elseif Player.TeamColor == BrickColor.new("Bright red") then --good game.Teams.Atlas.Score = game.Teams.Atlas.Score + 1 --See comment 2 script.Parent.Parent.Atlas.Text = game.Teams.Atlas.Score --See comment 2 end end) end) end)
Comment 1 It is unnecessary to
WaitForChild
because I figure that theChar
will have plenty of time to load before it can die Comment 2 I'm figuring thatScore
is a "IntValue" or "NumberValue". This means thatScore
is the Instance that contains the value, not the value itself so doing:
game.Teams.Sentinel.Score.Value = game.Teams.Sentinel.Score.Value + 1 ~~~~~~~~~~~~~~~~~' would be more appropriate. **NOW TO FIX THE SECOND PART OF YOUR QUESTION** Besides `leaderstats` being a model, and not a `IntValue` I don't see anything wrong with this, except some inefficiencies: There are two arguments in creating an `Instance` the first one is the Instance itself, and the second one is there the Instance is placed (This is more efficient than adding another line to assign a parent)
game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("IntValue", player) leaderstats.Name = "leaderstats" local Score = Instance.new("IntValue", leaderstats) Score.Name = "Score" Score.Value = 0 end) ~~~~~~~~~~~~~~~~~ Please accept if this helped