local module = {}
function module.addValue(path, number:number) path.Value += number; end
function module.removeValue(path, number:number) path.Value -= number; end
function module.setValue(path, number:number) path.Value = number; end
return module
local TweenService = game:GetService("TweenService")
local ConfigurationXP = require(game:GetService("ReplicatedStorage").Configuration.XP)
local changeDatas = require(game:GetService("ReplicatedStorage").Modules.ChangeDataValue)
local player = game.Players.LocalPlayer
local function calculBar()
if player.DS.Levels.Value ~= nil then
changeDatas.setValue(player.DS.Levels, 1)
end
if player.DS.Levels.Value then
if player.DS.EXP.Value >= ConfigurationXP.xpPerLevels[tonumber(player.DS.Levels.Value)] then
changeDatas.removeValue(player.DS.EXP, ConfigurationXP.xpPerLevels[tonumber(player.DS.Levels.Value)])
changeDatas.addValue(player.DS.Levels, 1)
local calcul = ConfigurationXP.xpPerLevels[tonumber(player.DS.Levels.Value)] - player.DS.EXP.Value
TweenService:Create(script.Parent.Level.Bar, TweenInfo.new(0.5), {Size = UDim2.new(1 / calcul, 0, 1, 0)}):Play()
script.Parent.Level.Label.Text = "LEVEL " .. tostring(player.DS.Levels.Value) .. " · " .. tostring(player.DS.EXP.Value) .. " EXP"
end
end
end
task.wait(1)
calculBar()
player.DS.EXP:GetPropertyChangedSignal('Value'):Connect(calculBar)
local buttons = script.Parent.Towers
local function ImageSize(path, Time, udim2)
TweenService:Create(path, TweenInfo.new(Time), {Size = udim2}):Play()
end
local function clickAnimation(path)
local clone = script.ClickAnimation:Clone()
clone.Parent = path
local tween = TweenService:Create(clone, TweenInfo.new(0.2), {Size = UDim2.new(1.2, 0, 1.2, 0)}); tween:Play()
tween.Completed:Connect(function()
local tween2 = TweenService:Create(clone, TweenInfo.new(0.085), {BackgroundTransparency = 1}); tween2:Play()
tween2.Completed:Connect(function() clone:Destroy(); end)
end)
end
buttons['1'].Button.MouseEnter:Connect(function() ImageSize(buttons['1'].Image, 0.15, UDim2.new(0.8, 0, 0.8, 0)); end)
buttons['1'].Button.MouseLeave:Connect(function() ImageSize(buttons['1'].Image, 0.15, UDim2.new(0.7, 0, 0.7, 0)); end)
buttons['1'].Button.MouseButton1Down:Connect(function() clickAnimation(buttons['1']); end)
buttons['2'].Button.MouseEnter:Connect(function() ImageSize(buttons['2'].Image, 0.15, UDim2.new(0.8, 0, 0.8, 0)); end)
buttons['2'].Button.MouseLeave:Connect(function() ImageSize(buttons['2'].Image, 0.15, UDim2.new(0.7, 0, 0.7, 0)); end)
buttons['2'].Button.MouseButton1Down:Connect(function() clickAnimation(buttons['2']); end)
buttons['3'].Button.MouseEnter:Connect(function() ImageSize(buttons['3'].Image, 0.15, UDim2.new(0.8, 0, 0.8, 0)); end)
buttons['3'].Button.MouseLeave:Connect(function() ImageSize(buttons['3'].Image, 0.15, UDim2.new(0.7, 0, 0.7, 0)); end)
buttons['3'].Button.MouseButton1Down:Connect(function() clickAnimation(buttons['3']); end)
buttons['4'].Button.MouseEnter:Connect(function() ImageSize(buttons['4'].Image, 0.15, UDim2.new(0.8, 0, 0.8, 0)); end)
buttons['4'].Button.MouseLeave:Connect(function() ImageSize(buttons['4'].Image, 0.15, UDim2.new(0.7, 0, 0.7, 0)); end)
buttons['4'].Button.MouseButton1Down:Connect(function() clickAnimation(buttons['4']); end)
buttons['5'].Button.MouseEnter:Connect(function() ImageSize(buttons['5'].Image, 0.15, UDim2.new(0.8, 0, 0.8, 0)); end)
buttons['5'].Button.MouseLeave:Connect(function() ImageSize(buttons['5'].Image, 0.15, UDim2.new(0.7, 0, 0.7, 0)); end)
buttons['5'].Button.MouseButton1Down:Connect(function() clickAnimation(buttons['5']); end)