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

How can I update this gui every time the number increases?

Asked by 7 years ago
local tool = script.Parent
Energy = 0

local player = game.Players.LocalPlayer

tool.Equipped:connect(function(mouse)
    local screenGui = Instance.new("ScreenGui")
screenGui.Parent = player.PlayerGui
local textLabel = Instance.new("TextLabel")
textLabel.Parent = screenGui
textLabel.Position = UDim2.new(0, 25, 0, 50)
textLabel.Size = UDim2.new(0, 150, 0, 50)
textLabel.BackgroundColor3 = BrickColor.White().Color
textLabel.Text = player.Name.."  Sah dude"..Energy


tool.Unequipped:connect(function(mouse)
    screenGui.Parent = nil
end)

end)


local tool = script.Parent
local keys = {}
tool.Equipped:connect(function(mouse)
    mouse.KeyDown:connect(function(key) keys[key] = true end)
    mouse.KeyUp  :connect(function(key) keys[key] = nil  end)
end)
while wait(0.2) do
    if keys["f"] then
        print "Charging"
        Energy = Energy + 5
    elseif keys["z"] and keys["x"] and Energy > 49 then
        print "Lol Idkek"
        wait(.5)
        Energy = Energy -50
    end
end


Whenever I hold down the F key, my energy increases by +5 every .2 seconds, but i would have to uneqeuip and then re-equip the tool in order for the number to change. Please help, cheers.

1 answer

Log in to vote
0
Answered by 7 years ago

It's because the script you are using is in the tool, and is only executed when the tool is equipped.

In order to fix that and make it work the way you want it to, you can change the text of the label in the while loop (for everytime the energy changes).

0
So, i didn't actually use what you said to fix it, but I did use what you said under consideration and made a repeat under the textlabel making it repeat the text until the parent of the screenGui is = to nil, thanks anyways, i'll still accept your answer for helping me accomplish this, lol, cheers :) Sparkflyer34 40 — 7y
Ad

Answer this question