Trying to make a simple energy meter whenever someone holds down the f key, but i would have to un-equip the tool and then re-equip the tool for the changes to take affect. I've already tried putting a repeat over the whole script, but that just crashes my game lol, any ideas?
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"] then
print "Lol Idkek"
end
end
