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

Script Broke, Any help?

Asked by 9 years ago

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:

01game.Workspace.ChildAdded:connect(function(child)
02 
03if child.Name == "HostageFree" then
04script.Sound:Play()--Don't worry about here and above
05 
06for _,player in pairs(game.Players:GetPlayers()) do 
07if player.TeamColor == BrickColor.Red() then 
08player.leaderstats.points.Name = player.leaderstats.Credits + 200 --Broken line
09 
10wait(7) --Don't worry about here and below
11local pl = game.Players:GetChildren()
12for i=1,#pl do
13pl[i].Character.Humanoid.Health = 0
14game.Workspace.HostageFree:Remove()
15end
16end
17end
18end
19end)

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

2 answers

Log in to vote
0
Answered by 9 years ago
01game.Workspace.ChildAdded:connect(function(child)
02 
03if child.Name == "HostageFree" then
04script.Sound:Play()--Don't worry about here and above
05 
06for _,player in pairs(game.Players:GetPlayers()) do 
07if player.TeamColor == BrickColor.Red() then 
08player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + 200 --Broken line
09 
10wait(7) --Don't worry about here and below
11local pl = game.Players:GetChildren()
12for i=1,#pl do
13pl[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]
14game.Workspace.HostageFree:Destroy() -- use destroy whenever possible.
15end
16end
17end
18end
19end)
0
I use the kill function to change player team colors and to remove their weapons CarterTheHippo 120 — 9y
0
Okay, well you can replace it if you want.. HungryJaffer 1246 — 9y
0
No its fine, but the script part where giving the players the points didnt work CarterTheHippo 120 — 9y
0
Changed it. HungryJaffer 1246 — 9y
View all comments (3 more)
0
I tried that too ealier myself, didnt work, read my updated notice CarterTheHippo 120 — 9y
0
Now try. HungryJaffer 1246 — 9y
0
i fixed it myself take a look below. CarterTheHippo 120 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Fixed it myself :p

01game.Workspace.ChildAdded:connect(function(child)
02 
03if child.Name == "HostageFree" then
04script.Sound:Play()
05 
06for _,player in pairs(game.Players:GetPlayers()) do 
07if player.TeamColor == BrickColor.Red() then
08local leaderstats = player.leaderstats
09local points = leaderstats:findFirstChild("Credits")
10points.Value  = points.Value +200
11 
12wait(7)
13local pl = game.Players:GetChildren()
14for i=1,#pl do
15pl[i].Character.Humanoid.Health = 0
View all 21 lines...
0
Sorry about the broken script, I didn't understand you on the points/credits part. HungryJaffer 1246 — 9y
0
its ok CarterTheHippo 120 — 9y

Answer this question