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

Why my game panel is adding more coins then normal?

Asked by 4 years ago
Edited 4 years ago

Hello once more, i am trying to do a race game,but when the players win,the first race it all goes okay,but in next,the player gets added more coins then normal?

Here is the script (Server-sided):

local ChangeText = game.ReplicatedStorage.GameTextShare
local Space = 1
local Maps = game.ReplicatedStorage.Maps:GetChildren()
while true do
    if #game.Players:GetPlayers() == 1 then
        ChangeText:FireAllClients(Space,"Not enough players! At least 2 players needed.")
        wait(1)
    else
        for i = 30,1,-1 do
            ChangeText:FireAllClients(Space,"Intermission: "..tostring(i))
            wait(1)
        end
        ChangeText:FireAllClients(Space, "Selecting random map...")
        wait(5)
        local SelectedMap = Maps[math.random(1, #Maps)]:Clone()
        SelectedMap.Parent = game.Workspace
        ChangeText:FireAllClients(Space, "Map Selected: "..SelectedMap.Name)
        wait(3)
        ChangeText:FireAllClients(Space, "Teleporting Players...")
        wait(3)
        ChangeText:FireAllClients(Space, "Get Ready!")
        wait(1)
        for i = 3,1,-1 do
            ChangeText:FireAllClients(Space, tostring(i))
            wait(1)
        end
        ChangeText:FireAllClients(Space, "Go!")
        wait(1)
        for i = 75,1,-1 do
            ChangeText:FireAllClients(Space, "Time Left: "..tostring(i))
            wait(1)
        end
        ChangeText:FireAllClients(Space, "Times up!")
        local Winners = require(game.ServerScriptService.PlaceOfPlayers) --Focus here and down
        if #Winners == 1 then
            game.Players[Winners[1]].leaderstats.Coins.Value += 250
        elseif #Winners == 2 then
            game.Players[Winners[1]].leaderstats.Coins.Value += 250
            game.Players[Winners[2]].leaderstats.Coins.Value += 150
        elseif #Winners >= 3 then
            game.Players[Winners[1]].leaderstats.Coins.Value += 200
            game.Players[Winners[2]].leaderstats.Coins.Value += 100
            game.Players[Winners[3]].leaderstats.Coins.Value += 50
            for i,v in pairs(Winners) do
                game.Players[v].leaderstats.Coins.Value += 50
            end
        end
        game.ReplicatedStorage.DeleteList:FireAllClients()
        for i,v in ipairs(Winners) do
            Winners[v] = nil
        end
        SelectedMap:Destroy()
        game.Workspace.PlaceGet.Value = 1
        print(#Winners)

        for i,v in pairs(game.Players:GetPlayers()) do
            v.Character.InWinner.Value = false
            v.Character.InPlace.Value = 0
        end

    end
end

If you need more information ask If it is a math problem sorry, i am not so good at it. Thanks.

0
This is most likely happening because you don't have any sort of `Debounce` in your script. Try adding one! zane21225 243 — 4y
0
Please somebody answer it my game depends on it ;-; yuni_Boy1234 320 — 4y

Answer this question