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

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

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!

3 comments

0

Yes this is possible

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.

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.

2 answers

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?

3 comments

0

the script can go in workspace as long as it's not a local script as workspace doesn't support local script

0

This doesn't work because you haven't defined leaderstats, and also the character added is unnecessary.

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.

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)

1 comment

0

NEVER use the client for writing data on leaderstats.

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