Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Energy drain script problems?

So I have this localscript in a weapon. It's intended to drain the bar value of the energy GUI when you fire the weapon, but it doesn't seem to be working properly. Anyone have any clue why?

BV = Player.StarterGui.BorgGui.BarValue

function onActivated()
	BV.Value = BV.Value - 5
end

3 comments

1

Did you connect or trigger the function?

1

To be honest, I've never worked with Localscripts before, so probably not. That's the entire code right there.

0

LocalScripts only differ from normal Scripts in that they run on the Client instead of the Server. You connect events and functions exactly the same way on both.

1 answer

BV = Player.StarterGui.BorgGui.BarValue

function onActivated()
while true do
wait(1)
if BV.Value > 5 then
    BV.Value = BV.Value - 5
elseif BV.Value =< 5 then
	BV.Value = 0
end
end
end

This should drain the energy to 0.

This discussion is preserved as it was. New answers, comments, and votes are closed.