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

The EXP Bar is not working correctly?

I need help on making an exp bar like the one similar to ROBLOX Deathrun. Is it possible to be assisted?

Here's the script:

-- This is in a local script

local bar = script.Parent
local xpbar = bar.EXPBar
local overlay = xpbar.Overlay
local player = game.Players.LocalPlayer

if player:FindFirstChild('leaderstats') then
	overlay:TweenSize(UDim2.new(player.EXP.Value/player.EXP.Value, 0, 1, 1, 0))
end

2 comments

0

There are 5 values for Udim2?

0

My fault.

1 answer

✓ Accepted answer
local player=game.Players.LocalPlayer
local bar=script.Parent
local xpbar=bar.EXPBar
local overlay=pbar.Overlay

player.EXP:Changed:connect(function(property) --This will check if the amount of EXP they have changed
	if property=="Value" then --This is checking if the property is value, value being the amount they have
		local exp=player.EXP[property] --This will get the amount of EXP they have
		local expMath=exp/(ExpValueNeededGoesHere) --If they have all the EXP needed (100/100 for example), expMath will equal 1, and take up the entire bar. If they're 50/100, it will equal .5 and take up half
		overlay:TweenSize(UDim2.new(expMath,0,1,0) --Tween from its current position to the new one
	end
end)

This SHOULD work. I can't really help as much, as I do not know where everything is.

4 comments

0

You should try to explain to them how you came to your solution. Simply doing it for them without explaining your thought process is a bad way of advancing knowledge.

0

Does it work, though?

0

Nope

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