I solved this by using a tutorial. But thanks to the comments for helping!
Put a screengui in startergui, then put a textbutton. For the leaderstats, put this code into ServerScriptService:
01 | --leaderstats code |
02 | local function onPlayerJoin(player) |
03 | local leaderstats = Instance.new( "Folder" ) |
04 | leaderstats.Name = "nameyouwant" |
05 | leaderstats.Parent = player |
06 |
07 | -- Display an 'IntValue' on leaderboard |
08 | local gold = Instance.new( "IntValue" ) |
09 | gold.Name = "yourname" |
10 | gold.Value = 0 |
11 | gold.Parent = leaderstats |
12 | end |
13 |
14 | -- Run 'onPlayerJoin()' when the 'PlayerAdded' event fires |
15 | game.Players.PlayerAdded:Connect(onPlayerJoin) |
01 | while true do |
02 | wait() |
03 | if script.Parent.Activated then |
04 | local leaderboard = game.Players.LocalPlayer:FindFirstChild( "leaderstats" ) |
05 | local respect = leaderboard:FindFirstChild( "Respect" ) |
06 | respect.Value = respect.Value + 1 |
07 | local audio = workspace:FindFirstChild( "RESPECT THE VETS" ) |
08 | audio:Play() |
09 | script.Parent.BackgroundTransparency = 0.5 |
10 | wait( 1 ) |
11 | script.Parent.BackgroundTransparency = 0 |
12 | end |
13 | end |
my script