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

How do i change a gui's label using a value?

Asked by 7 years ago

Im trying to make an script that you fly, and if you keep flying you lose Ki.

i made the script, the Ki appears on the GUI, but the ki doesnt change. Please Help

local n = game.Players.LocalPlayer.PlayerGui.ScreenGui.Ki
while script.Parent.Activated == true do
n.Value = (n.Value - 1)
    wait(1)
end

2 answers

Log in to vote
0
Answered by
LuaDLL 253 Moderation Voter
7 years ago

This Might Work.

local n = game.Players.LocalPlayer.PlayerGui.ScreenGui.Ki
while script.Parent.Activated == true do
n.Value = (n.Value - 1)
    game.Players.LocalPlayer.PlayerGui.ScreenGui.PUTTEXTLABELNAMEHERE.Text = n.Value
    wait(1)
end

0
it didnt work, but thx PowerfullPow 0 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

You are trying to change an IntValue's value through a LocalScript, I would suggest doing this;

local ki = 100 --change 100 to whatever amount is your default ki will be
local maxKi = 100 --change 100 to whatever to set the max ki a player will have
while script.Parent.Activated == true do
    ki = ki - 1
    if ki <= 0 then break end
    wait(1)
end

First, we are going to define ki as 100 and maxKi as 100. Ki will be your default/regular amount of ki your player will have. The maxKi just means the maximum amount of ki a player will have. Although they are just defined as int value meaning they are numbers until you used them correctly, like show above. Next while the player is clicking down with a tool, the ki will decrease by 1 every second (which you know already). If ki is less than or equal to 0 then it will stop the while loop and skip the while function.

Answer this question