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:

game.Workspace.ChildAdded:connect(function(child) 

if child.Name == "HostageFree" then 
script.Sound:Play()--Don't worry about here and above

for _,player in pairs(game.Players:GetPlayers()) do  
if player.TeamColor == BrickColor.Red() then  
player.leaderstats.points.Name = player.leaderstats.Credits + 200 --Broken line

wait(7) --Don't worry about here and below
local pl = game.Players:GetChildren()
for i=1,#pl do
pl[i].Character.Humanoid.Health = 0
game.Workspace.HostageFree:Remove()
end
end 
end
end 
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

2 answers

Log in to vote
0
Answered by 9 years ago
game.Workspace.ChildAdded:connect(function(child) 

if child.Name == "HostageFree" then 
script.Sound:Play()--Don't worry about here and above

for _,player in pairs(game.Players:GetPlayers()) do  
if player.TeamColor == BrickColor.Red() then  
player.leaderstats.Credits.Value = player.leaderstats.Credits.Value + 200 --Broken line

wait(7) --Don't worry about here and below
local pl = game.Players:GetChildren()
for i=1,#pl do
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]
game.Workspace.HostageFree:Destroy() -- use destroy whenever possible.
end
end 
end
end 
end) 

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

game.Workspace.ChildAdded:connect(function(child) 

if child.Name == "HostageFree" then 
script.Sound:Play()

for _,player in pairs(game.Players:GetPlayers()) do  
if player.TeamColor == BrickColor.Red() then 
local leaderstats = player.leaderstats
local points = leaderstats:findFirstChild("Credits") 
points.Value  = points.Value +200

wait(7)
local pl = game.Players:GetChildren()
for i=1,#pl do
pl[i].Character.Humanoid.Health = 0
game.Workspace.HostageFree:Remove()
end
end 
end
end 
end) 
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