I have this script, and the line it breaks on is "player.leaderstats.points.Name = player.leaderstats.Credits + 200" The reason is the stats on the leader are points but are named under Credits.
This is the script:
01 | game.Workspace.ChildAdded:connect( function (child) |
02 |
03 | if child.Name = = "HostageFree" then |
04 | script.Sound:Play() --Don't worry about here and above |
05 |
06 | for _,player in pairs (game.Players:GetPlayers()) do |
07 | if player.TeamColor = = BrickColor.Red() then |
08 | player.leaderstats.points.Name = player.leaderstats.Credits + 200 --Broken line |
09 |
10 | wait( 7 ) --Don't worry about here and below |
11 | local pl = game.Players:GetChildren() |
12 | for i = 1 ,#pl do |
13 | pl [ i ] .Character.Humanoid.Health = 0 |
14 | game.Workspace.HostageFree:Remove() |
15 | end |
16 | end |
17 | end |
18 | end |
19 | end ) |
NOTICE: the leaderboard stat is points but I named them Credits so when it appears on players leaderboard ingame it appears as Credits but still is referred to as points in script. But you have to add +200 to Credits
01 | game.Workspace.ChildAdded:connect( function (child) |
02 |
03 | if child.Name = = "HostageFree" then |
04 | script.Sound:Play() --Don't worry about here and above |
05 |
06 | for _,player in pairs (game.Players:GetPlayers()) do |
07 | if player.TeamColor = = BrickColor.Red() then |
08 | player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + 200 --Broken line |
09 |
10 | wait( 7 ) --Don't worry about here and below |
11 | local pl = game.Players:GetChildren() |
12 | for i = 1 ,#pl do |
13 | pl [ i ] :LoadCharacter() -- This is a faster way of resetting them. If you've ever used an admin script, this would be the equivalent of :Respawn [person] |
14 | game.Workspace.HostageFree:Destroy() -- use destroy whenever possible. |
15 | end |
16 | end |
17 | end |
18 | end |
19 | end ) |
Fixed it myself :p
01 | game.Workspace.ChildAdded:connect( function (child) |
02 |
03 | if child.Name = = "HostageFree" then |
04 | script.Sound:Play() |
05 |
06 | for _,player in pairs (game.Players:GetPlayers()) do |
07 | if player.TeamColor = = BrickColor.Red() then |
08 | local leaderstats = player.leaderstats |
09 | local points = leaderstats:findFirstChild( "Credits" ) |
10 | points.Value = points.Value + 200 |
11 |
12 | wait( 7 ) |
13 | local pl = game.Players:GetChildren() |
14 | for i = 1 ,#pl do |
15 | pl [ i ] .Character.Humanoid.Health = 0 |