Aight, it’s pretty messy…
local script
local tweenService = game:GetService("TweenService")
local gameSets = require(game.ReplicatedStorage.GameSettings)
local player = game.Players.LocalPlayer
local upgradesFrame = player.PlayerGui:WaitForChild("MainGUI").UpgradesFrame
local rFunc = game.ReplicatedStorage:WaitForChild("Functions"):WaitForChild("ChangeData")
local db = false
local menuOpen = false
upgradesFrame.Parent.DataFrame.Background.Holder.SkillUpgrades.MouseButton1Click:Connect(function()
if menuOpen == false then
menuOpen = true
upgradesFrame.Visible = true
local tweenMenu = tweenService:Create(upgradesFrame, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = UDim2.new(0.5, 0, 0.5, 0)})
tweenMenu:Play()
local tweenBlur = tweenService:Create(game.Lighting.BackgroundBlur, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Size = 12})
tweenBlur:Play()
else
menuOpen = false
local tweenMenu = tweenService:Create(upgradesFrame, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Position = UDim2.new(0.5, 0, 2, 0)})
tweenMenu:Play()
local tweenBlur = tweenService:Create(game.Lighting.BackgroundBlur, TweenInfo.new(0.5, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Size = 0})
tweenBlur:Play()
tweenMenu.Completed:Connect(function()
upgradesFrame.Visible = false
end)
end
end)
while wait() do
local data = game.ReplicatedStorage:WaitForChild("Functions"):WaitForChild("ReturnData"):InvokeServer(player)
if data then
local SetPoints = data.Points
local upgrades = upgradesFrame.Background.Holder
print(data.Points)
upgrades.Strength.Background.Upgrade.MouseButton1Click:Connect(function()
if tonumber(SetPoints) ~= 0 then
if db == false then
db = true
rFunc:InvokeServer("Points", 1, "-")
rFunc:InvokeServer("Strength", 1, "+")
task.wait()
db = false
end
end
end)
upgrades.Defense.Background.Upgrade.MouseButton1Click:Connect(function()
if tonumber(SetPoints) ~= 0 then
if db == false then
db = true
rFunc:InvokeServer("Points", 1, "-")
rFunc:InvokeServer("Defense", 1, "+")
task.wait()
db = false
end
end
end)
upgrades.CritChance.Background.Upgrade.MouseButton1Click:Connect(function()
if tonumber(SetPoints) ~= 0 then
if db == false then
db = true
rFunc:InvokeServer("Points", 1, "-")
rFunc:InvokeServer("CritChance", 1, "+")
task.wait()
db = false
end
end
end)
upgrades.Stamina.Background.Upgrade.MouseButton1Click:Connect(function()
if tonumber(SetPoints) ~= 0 then
if db == false then
db = true
rFunc:InvokeServer("Points", 1, "-")
rFunc:InvokeServer("Stamina", 1, "+")
task.wait()
db = false
end
end
end)
upgrades.Parent.Points.Text = "You have " .. data.Points .. " Point(s)"
upgrades.Strength.Background.Upgrade.Text = "Upgrade (Lv. " .. data.Strength .. ")"
upgrades.Defense.Background.Upgrade.Text = "Upgrade (Lv. " .. data.Defense .. ")"
upgrades.CritChance.Background.Upgrade.Text = "Upgrade (Lv. " .. data.CritChance .. ")"
upgrades.Stamina.Background.Upgrade.Text = "Upgrade (Lv. " .. data.Stamina .. ")"
upgradesFrame.Parent.DataFrame.Background.Holder.CashText.Text = "$" .. data.Cash
end
end
dataHandler
local Players = game:GetService("Players")
local datastoreService = game:GetService("DataStoreService")
local playerData = datastoreService:GetDataStore("playerData" .. 39)
local notificationsMod = require(game:GetService("ServerStorage"):WaitForChild("NotificationHandler"))
local PlayerHandler = {}
local sessionData = {}
local function setupData(player)
local plrUserId = player.UserId
local data
local success = pcall(function()
data = playerData:GetAsync(plrUserId)
end)
if success then
if data then
sessionData[plrUserId] = data
else
sessionData[player.UserId] = {
Level = 1,
Cash = 100,
Exp = 0,
Points = 1,
Strength = 1,
Defense = 1,
CritChance = 1,
Stamina = 1,
}
end
end
end
local function saveData(player)
local plrUserId = player.UserId
local success = pcall(function()
playerData:SetAsync(plrUserId, sessionData[player.UserId])
end)
end
function PlayerHandler.ChangeValue(player, name, value, symbol)
local selectedSymbol
if symbol then
selectedSymbol = symbol
else
selectedSymbol = "+"
end
local plrUserId = player.UserId
if sessionData[plrUserId] then
if selectedSymbol == "+" then
sessionData[plrUserId][name] = tonumber(sessionData[plrUserId][name]) + value
notificationsMod.CreateNotification(player, "Increased " .. name .. " by " .. value .. "!")
elseif selectedSymbol == "-" then
sessionData[plrUserId][name] = tonumber(sessionData[plrUserId][name]) - value
notificationsMod.CreateNotification(player, "Decreased " .. name .. " by " .. value .. "!")
elseif selectedSymbol == "*" then
sessionData[plrUserId][name] = tonumber(sessionData[plrUserId][name]) * value
notificationsMod.CreateNotification(player, "Multiplied " .. name .. " by " .. value .. "!")
elseif selectedSymbol == "/" then
sessionData[plrUserId][name] = tonumber(sessionData[plrUserId][name]) / value
notificationsMod.CreateNotification(player, "Divided " .. name .. " by " .. value .. "!")
elseif selectedSymbol == "=" then
sessionData[plrUserId][name] = value
end
end
end
Players.PlayerAdded:Connect(setupData)
Players.PlayerRemoving:Connect(saveData)
function PlayerHandler.ReturnData(player)
return sessionData[player.UserId]
end
game.ReplicatedStorage:WaitForChild("Functions"):WaitForChild("ReturnData").OnServerInvoke = function(player)
return sessionData[player.UserId]
end
game.ReplicatedStorage:WaitForChild("Functions"):WaitForChild("ChangeData").OnServerInvoke = function(player, name, value, symbol)
PlayerHandler.ChangeValue(player, name, value, symbol)
end
return PlayerHandler
I can’t provide any videos, I can’t figure out how to make a video on this