#How do i fix this, so it loads the actual amount when the player joins?

1 messages · Page 1 of 1 (latest)

vernal onyx
#

BRUH I JUST A DUMBASS DW!!!!

SPENT LIKE 10HRS ON ON THING I AM GONNA CRY

dark warren
#

send code pls

vernal onyx
#

whats the difference?

#

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Remotes = ReplicatedStorage.Remotes

local Manager = {}

Manager.Profiles={}

function Manager.AdjustClicks(player: Player, amount: number)
local profile = Manager.Profiles[player]
if not profile then return end
profile.Data.Clicks += amount
player.leaderstats.Clicks.Value = profile.Data.Clicks
Remotes.UpdateClicks:FireClient(player, profile.Data.Clicks)
end

local function GetData (player:Player, directory: string)
local profile = Manager.Profiles[player]
if not profile then return end
return profile.Data[directory]

end

Remotes.GetData.OnServerInvoke = GetData

return Manager

#

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local FormatNumber = require(ReplicatedStorage.Libs.FormatNumber.Simple)

local Remotes = ReplicatedStorage.Remotes

local Gui = script.Parent
local Frame = Gui.Frame

local FormatNumber = require(ReplicatedStorage.Libs.FormatNumber.Simple)

local Clicks = Frame.Clicks.Amount
local DamagePerSec =Frame.Clicks.DPS
local BuyClicks = Frame.Clicks.Buy
local Gems = Frame.Gems.Amount

local function UpdateCurrency(currency:"Clicks"| "Gems", amount: number)
amount = FormatNumber.FormatCompact(amount)

if currency == "Clicks" then
    
    Clicks.Text = amount
elseif currency == "Gems" then
    Gems.Text = amount
end

end

UpdateCurrency("Clicks", Remotes.GetData:InvokeServer("Clicks"))

Remotes.UpdateClicks.OnClientEvent:Connect(function(amount)
UpdateCurrency("Clicks", amount)
end)

#

Using a remoteFunction.

dark warren
#
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Remotes = ReplicatedStorage.Remotes

local Manager = {}

Manager.Profiles = {}

function Manager.AdjustClicks(player: Player, amount: number)
    local profile = Manager.Profiles[player]
    if not profile then return end
    profile.Data.Clicks += amount
    player.leaderstats.Clicks.Value = profile.Data.Clicks
    Remotes.UpdateClicks:FireClient(player, profile.Data.Clicks)
end

local function GetData(player: Player, directory: string)
    local profile = Manager.Profiles[player]
    if not profile then return end
    return profile.Data[directory]
end

Remotes.GetData.OnServerInvoke = GetData

return Manager
#
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local FormatNumber = require(ReplicatedStorage.Libs.FormatNumber.Simple)
local Remotes = ReplicatedStorage.Remotes
local Gui = script.Parent
local Frame = Gui.Frame

local Clicks = Frame.Clicks.Amount
local Gems = Frame.Gems.Amount

local function UpdateCurrency(currency: "Clicks" | "Gems", amount: number)
    amount = FormatNumber.FormatCompact(amount)
    if currency == "Clicks" then
        Clicks.Text = amount
    elseif currency == "Gems" then
        Gems.Text = amount
    end
end

UpdateCurrency("Clicks", Remotes.GetData:InvokeServer("Clicks"))

Remotes.UpdateClicks.OnClientEvent:Connect(function(amount)
    UpdateCurrency("Clicks", amount)
end)