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

Money giving script doesnt work. How can i solve it ? It is a sword game

Asked by 4 years ago
Edited 4 years ago

I made a sword game and i made a function which is giving money to winner. But it doesnt work

01local mapstoragechild = game.Workspace.MapStorage:GetChildren()
02local players = game.Players:GetPlayers()
03local message = game.Workspace.Message
04local rp = game.Workspace.MapStorage.Map.PlayerStorage:GetChildren()
05function tpbak()
06    for i = 1,#rp do
07        rp[i].Humanoid.Health = 0
08    end
09end
10while #mapstoragechild == 1 do
11    local playerleft = game.Workspace.MapStorage.Map.PlayerStorage:GetChildren()
12    function gibmw()
13        local plp = playerleft:GetPlayerFromCharacter()
14        for i = 1, #playerleft do
15            plp[i].leaderstats.Money.Value = plp[i].leaderstats.Money.Value + 10
View all 36 lines...
0
have you put it in a script or a local script? esepek 103 — 4y
0
You have to show the entire script since you didn't show what is the value of "playerleft". User#32819 0 — 4y
0
ok Omerevkizel 27 — 4y
0
your script confuses me dionsyran2 66 — 4y

2 answers

Log in to vote
0
Answered by
esepek 103
4 years ago

I helped solving and we dont really know what was wrong because i just did an in pairs function to loop throught the remaining players and it worked!

Ad
Log in to vote
0
Answered by 4 years ago

i would change line 14 - 17 to:

1for index, player in pairs(players) do
2    player.leaderstats.Money.Value = player.leaderstats.Money.Value + 10
3    end
4end

Answer this question