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

How to make a GUI that'll change a leaderboard string value?

I want a Job system in which when you choose your job, i'll change your "Job" on the leaderboard, this works with StringValues but I can't get it to work, any help? heres the script

**game.Players.PlayerAdded:connect(function (p) local lead = Instance.new("IntValue") lead.Name = "leaderstats" local rank = Instance.new("StringValue", lead) rank.Name = "Job" rank.Value = "Unemployed" rank.Parent = lead --wait() lead.Parent = p --print(rank:GetFullName())

game.StarterGui.ScreenGui.Frame.TextLabel.Farmer.TextButton.MouseButton1Click:Connect(function(cat) local function cat() if rank.Value == "Unemployed" then rank.Value.Changed = "Farmer" else rank.Value = "Unemloyed" end

end end)

end)**

5 comments

0

So in your case, you want a TextLabel to have text as the StringValue has?

0

Nope, I want the text in the leaderboard (here, is unemployed for now); but when you'll click a button called "Farmer", the leaderboard will change the StringValue "Unemployed" to "Farmer"

0

Please make this more readable, please. Its hard to understand if it is one script or two, place the script(s) in a code block so i and others have an easier time answering.

0

You can use a RemoteEvent to send a message from a local script to a server script to fire a function on the server changing the "Job" of the player when the button is clicked

0

Also you're indexing through the StarterGui, which is what holds the Guis that the player starts with, not the Guis that the player has, so you should rewrite your code in a Local Script and use game:GetService("Players").LocalPlayer.PlayerGui instead of StarterGui

1 answer

Okay I found your issue (hopefully):

This line game.StarterGui.ScreenGui.Frame.TextLabel.Farmer.TextButton.MouseButton1Click:Connect(function(cat) You can Simplify this by using LocalScript, but instead of game.StarterGui, use player.PlayerGui since StartGui is a service and can do nothing. and what is at fault is the if statement.

Just simplify the script by doing:

button.MouseButton1Click:Connect(function()
rank.Value = "Farmer"
end)

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