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

How do I make LeaderBoard update on a function?

Asked by 7 years ago
Edited 7 years ago

im breaking my head to try and figure this out but i cant!!!!

Leaderboard script

function onPlayerEntered(newPlayer)

    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"

    local cash = Instance.new("IntValue")
    cash.Name = "Money"       
    cash.Value = 0 

    cash.Parent = stats
    stats.Parent = newPlayer
end


game.Players.ChildAdded:connect(onPlayerEntered)

so that's that. I have a block deleter and I want it so when ever a block gets removed the leaderboard gives the player +1 Money

The block deleter script

local function Check(hit)
if hit.Name == "Brick" then
    wait(0.2) hit:Remove("Brick")
end
end

script.Parent.Touched:connect(Check)

Help please?

0
game.Players.leaderstats.Money.Value = game.Players.leaderstats.Money.Value + 1 -- Place this after line 3 Karl_RBX 11 — 7y
0
You should also use Destroy() instead of Remove() mattscy 3725 — 7y
0
Line 3 on which script? SwagnLag -2 — 7y
0
Nvm I got it SwagnLag -2 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Use Destroy() not Remove(), try using PlayerAdded instead of ChildAdded on game.Players.

The answer is pretty simple:

local function Check(hit)
if hit.Name == "Brick" then
wait(0.2)
hit:Destroy()
game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value + 1 -- Change to how you like it
end
end

script.Parent.Touched:connect(Check) 
-- From a LocalScript running on the client
0
Let me try SwagnLag -2 — 7y
0
it doesn't work SwagnLag -2 — 7y
0
nvm SwagnLag -2 — 7y
Ad

Answer this question