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?
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