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

How to Awarding Points/Coins?

Asked by 9 years ago

My own waves script Everything works fine only one important thing doesn't work: Awarding Points/Coins after complete wave (Disaster) [NOT PLAYERPOINTS] <-- Just saying I do like to add more diffrent points like Complete 25 waves complete but that is what i add soon but i need to let work first the awarding points. I tried alot but its everytime not working Does anybody know how to fix this?

Maybe i need explain the script, First part i just added 3 waves yet but this look green lines but this doesn't been changed bc it work perfect.

local A = "Map1"
local B = "Map2"
local C = "Map3"
local D = "Map4"
local E = "Map5"
local Lighting = game.ServerStorage
local Choos = 0
local leaderboard = game.Workspace:findFirstChild("leaderboard")

game.Players.PlayerAdded:wait()

while true do
    Choos = math.random(1)
    wait(10)
    if Choos == 1 then
        Lighting:findFirstChild(A):clone().Parent = game.Workspace
        wait (5)
------------------------------------- Wave one below
        Lighting:findFirstChild("M1W1"):clone().Parent = game.Workspace
        for i, v in   pairs(game.Players:GetChildren()) do  v.Character.Torso.CFrame = CFrame.new(Vector3.new(-37.161, 43.18, 72.114))  
            end
        wait(25)
        if game.Workspace:FindFirstChild("M1W1") then
        for i, v in   pairs(game.Players:GetChildren()) do  v.Character.Torso.CFrame = CFrame.new(Vector3.new(-40.361, 138.18, 62.914)) 
            end
        game.Workspace:FindFirstChild(A):Destroy() 
        else
------------------------------------- Wave 2 below
        leaderboard.Points.Value + 10
        Lighting:findFirstChild("M1W2"):clone().Parent = game.Workspace
        for i, v in   pairs(game.Players:GetChildren()) do  v.Character.Torso.CFrame = CFrame.new(Vector3.new(-37.161, 43.18, 72.114))  
            end
        wait(15)
            if game.Workspace:FindFirstChild("M1W2") then
            for i, v in   pairs(game.Players:GetChildren()) do  v.Character.Torso.CFrame = CFrame.new(Vector3.new(-40.361, 138.18, 62.914)) 
                end
            game.Workspace:FindFirstChild(A):Destroy()
            else
------------------------------------- Wave 3 below
            Lighting:findFirstChild("M1W3"):clone().Parent = game.Workspace
            wait(15)
                if game.Workspace:FindFirstChild("M1W3") then
                for i, v in   pairs(game.Players:GetChildren()) do  v.Character.Torso.CFrame = CFrame.new(Vector3.new(-40.361, 138.18, 62.914)) 
                    end
                game.Workspace:FindFirstChild(A):Destroy()
                else
                Lighting:findFirstChild("M1W4"):clone().Parent = game.Workspace
                wait(15)
                end
            end
        end
        wait (1)
    end
end

1 answer

Log in to vote
0
Answered by 9 years ago

Before we start (You don't have to do this) Lighting is not a good method to store things in anymore. ServerStorage was created for this specific reason and I recommend you switch over to it.

Solution

Were going to use the leaderstats value in the player to change there Coins/Points. When you create a "regular" leaderboard you create a intvalue in the player called leaderstats. Inside the intvalue you have your values for your leaderboard. But, we can't do anything until we find the player's name. You will need to figure a way to grab the player's name. So we will begin by creating a variable named player.

player = -- Find a way to track the player.

Then what we want to do is access the player's leaderstat value. To get this were going to use:

player = -- Find a way to track the player.

game.Players[player].leaderstats

Once we have found the directory of the leaderstats value we need to get the value of the Point/Coin stat itself, which is with-in the leaderstat value. We must also remember to put .Value at the end of the Point/Coin value.

player = -- Find a way to track the player.

game.Players[player].leaderstats.Coin.Value

Then what we will need to do is change the value of "Coin." To add to the value put a "=" then copy and paste the directory of the Coin value and put in how much you want it to add. Example: "+100" will add 100 to the value.

player = -- Find a way to track the player.

game.Players[player].leaderstats.Coin.Value = game.Players[player].leaderstats.Coin.Value +100

You can subtract the number by changing it to "-100" Keep in mind that if your Coin value is a StringValue it will not add/subtract, you will need to change it to a IntValue in the leaderboard script. If you want to change it to a specific number make it:

player = -- Find a way to track the player.

game.Players[player].leaderstats.Coin.Value = "100" -- Makes the value 100

References

Leaderboard (ROBLOX Wiki) IntValue (ROBLOX Wiki) StringValue (ROBLOX Wiki)

If this answered your question please accept this answer.

0
Thanks dude, and for the tips about Lighting ;) minetrackmania 186 — 9y
0
I dont find the player. minetrackmania 186 — 9y
Ad

Answer this question