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

How would I make a button that will take away leaderstats?

Asked by 1 year ago

So I am trying to make a shop and how would I be able to make it so that when you click a text button it checks you have 75 Blocks(the leaderstat) and if it does, it takes away 75,

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
1 year ago
local Button = script.Parent
local Player = game:GetService("Players").LocalPlayer

Button.MouseButton1Click:Connect(function() 
    if Player.leaderstats.Blocks.Value >= 75 then -- Checks if player have 75 or more blocks
        Player.leaderstats.Blocks.Value -= 75 -- Takes away 75 blocks from the player
    end
end)

This code uses the MouseButton1Click event, which is triggered when a button is clicked. After you click it checks if you at least have 75 blocks, if so, it takes away 75 blocks from the player.

However, this is a really basic script. If you require future assistance, I recommend you check out some Roblox tutorials to gain familiarity with the subject.

Ad

Answer this question