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

[SOLVED] Is it possible to make a leaderstat increase via buttons? Please read desc, thx

Asked by 3 years ago
Edited 3 years ago

So i'm very new to scripting and I don't know anything pretty much. I'm wondering if it's possible to make a frame and inside insert a textbox with no text, and a textbutton with the text "give". What I want to know how to do if how to make it so when I type in a roblox username in the textbox, it checks if that roblox username [roblox player] is in the game and if they are in the game when I click give and their username is in the textbox in the "Wins" stat of leaderstat the stat increases by 1. I hope I said it clear enough to were someone can help me, thanks!

0
Yes this is possible MattVSNNL 620 — 3y
0
I can do this, though I don't have the time to explain. If you contact the Discord in my Bio, I'll help you from there later in the day. My time is MST. Ziffixture 6913 — 3y
0
Ok, Ziffixture I sent you a friend request on discord. If we can talk soon that'll be great. Hope we both are online at a time so we can talk and u can help me. Nitrolux200 62 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

I'll try to help, I'm not sure if this will work though.

local Players = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(chr)
        local chrname = chr.Name
        if chrname = "Nitrolux200" then
            -- Grab Leaderstats, then change the leaderstat for the user by 1.
        end
    end)
end)

Sorry that I had to cut a bit out, I'm sort of a beginner too, but I hope some of this code helped. I'm pretty sure the script can go in Workspace?

0
the script can go in workspace as long as it's not a local script as workspace doesn't support local script WINDOWS10XPRO 438 — 3y
0
This doesn't work because you haven't defined leaderstats, and also the character added is unnecessary. Dovydas1118 1495 — 3y
0
I don't understand any of that, srry. What i'm looking for is to add a textbox and a give button. I put down a username in the textbox and when I press give the script checks if the player is in the game and if the player is in the game then they get +1 of the leaderstat that i chose. Nitrolux200 62 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
local frame = script.Parent
local textbox = frame.TextBox
local textbutton = frame.TextButton

game.Players.PlayerAdded:Connect(function(player)
    textbutton.MouseButton1Click:Connect(function()
        local findplayer = Player:FindFirstChild(textbox.Text)
        if findplayer then
            findplayer.leaderstats.Coins.Value = findplayer.leaderstats.Coins.Value + 1
        end
    end)
end)
0
NEVER use the client for writing data on leaderstats. Dovydas1118 1495 — 3y

Answer this question