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

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

Asked by 5 years ago
Edited 5 years ago

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)**

0
So in your case, you want a TextLabel to have text as the StringValue has? NickAtNick 163 — 5y
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" Hamistur 2 — 5y
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. popgoesme700 113 — 5y
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 MegaManSam1 207 — 5y
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 MegaManSam1 207 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
Ad

Answer this question