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 3 years ago
Edited 3 years ago

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

local mapstoragechild = game.Workspace.MapStorage:GetChildren()
local players = game.Players:GetPlayers()
local message = game.Workspace.Message
local rp = game.Workspace.MapStorage.Map.PlayerStorage:GetChildren()
function tpbak()
    for i = 1,#rp do
        rp[i].Humanoid.Health = 0
    end
end
while #mapstoragechild == 1 do
    local playerleft = game.Workspace.MapStorage.Map.PlayerStorage:GetChildren()
    function gibmw()
        local plp = playerleft:GetPlayerFromCharacter()
        for i = 1, #playerleft do
            plp[i].leaderstats.Money.Value = plp[i].leaderstats.Money.Value + 10 
        end
    end
    if #playerleft == 1 then
        gibmw()
        tpbak()
        wait(2)
        game.Workspace.MapStorage:ClearAllChildren()
        script.Parent.Gameselect.Disabled = true
        wait(3)
        script.Parent.Intermission.Disabled = false
        game.Workspace.Gamemode.Value = 0
        message.Value = "Game Ended !"
        game.Workspace.Songs.Songloop.Disabled = false
        wait(1)
        script.Parent.Gameselect.Disabled = false
        script.Disabled = true
        break
    end
    wait(0.1)
end
--This script making 1 player left then shut the gametime and tp players and gib rewards
0
have you put it in a script or a local script? esepek 103 — 3y
0
You have to show the entire script since you didn't show what is the value of "playerleft". User#32819 0 — 3y
0
ok Omerevkizel 27 — 3y
0
your script confuses me dionsyran2 66 — 3y

2 answers

Log in to vote
0
Answered by
esepek 103
3 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 3 years ago

i would change line 14 - 17 to:

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

Answer this question