Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make LeaderBoard update on a function?

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?

4 comments

0

game.Players.leaderstats.Money.Value = game.Players.leaderstats.Money.Value + 1 -- Place this after line 3

0

You should also use Destroy() instead of Remove()

0

Line 3 on which script?

0

Nvm I got it

1 answer

✓ Accepted answer

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

3 comments

0

Let me try

0

it doesn't work

0

nvm

This discussion is preserved as it was. New answers, comments, and votes are closed.