Meter/Bar Updates

Hello, I am currently creating a game with a bar/meter but I don’t know the best way to make it.
This is what it looks like.

It is located in starter gui with a background and the meter/bar itself.

image

I have experimented with it before and have made the bar change depending on an int value called “value”

Here is the script:

local plr = game.Players.LocalPlayer

local Character = plr.Character

local char = Character:WaitForChild(“Humanoid”)

local value = game.StarterGui.Value

local Meter = script.Parent

value.Changed:Connect(function()

Meter.Size = UDim2.new(value.Value/100,0,1,0)

end)

The problem is I don’t know if this is efficient. Also, I want to be able to change the amount based on actions like using a tool or being in a region and I want effects to take place like killing the player if the bar hits 0 which I think can be done with remote events to the server. I’m not asking for a full script I just want some links, answers, or suggestions.

Hello there!

The script that you providet is efficent, but if you would like to achieve some smooth resizing, then you could possibly use the TweenService.

There are many usages of this kind of bar, but I think you should still be relying on different Values and not a size of the Bar, as it will be easier to orientate in and it will be easier to change as well.

Now I will try to quickly comment the thing you mentioned about killing the player:

the choice whether if it would be better to use a RemoteEvents or some other kind of approach really depends on the situation. Whatever if you would chose the RemoteEvent way, then I will suggest you keeping the RemoteEvent secure! You can see more of how can you keep your game secure in this video:

I hope I was able to help you!
Have a nice rest of your day!

1 Like