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

How would i make the value strength upgrades by connected with a text label?

Asked by
Prestory 1395 Moderation Voter
6 years ago

So i have a value which is called strength and every time you click it picks a random number from 1 to 10 how would i make it change the text to how much it upgraded by when it picks a random number from 1 to 10 for example if it upgrades by +3 it would say +3 on the text label this is the code

game.Players.LocalPlayer.leaderstats.Strength.Value = game.Players.LocalPlayer.leaderstats.Strength.Value + math.random(1,script.Parent.Handle.Value.Value)

I would appreciate help thanks!

1 answer

Log in to vote
1
Answered by 6 years ago

I noticed that you were changing the leaderstats values with a localscript. I'm hoping this is intentional, because that will not work with FilteringEnabled servers. Assuming this is intentional, here's how you would do it.

You'll want to have a PlayerGui with a TextLabel in it already set up, adjust the variables below to make it work for your use case.

local player = game.Players.LocalPlayer -- This just makes it easier to script.
local textlabel = player.PlayerGui.MYGUI.MYTEXTLABEL -- You replace this of course.
local value = math.random(1,script.Parent.Handle.Value.Value) -- Store your value in a variable.

player.leaderstats.Strength.Value = player.leaderstats.Strength.Value + value -- Your code.
textlabel.Text = "+"..value
0
THANKS ALOT! Prestory 1395 — 6y
Ad

Answer this question