#Gui & Leadertstats/Data are not in sync
1 messages · Page 1 of 1 (latest)
Template:
Clicks = 0,
Yens = 0,
Gems = 0
}```
Manager:
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local Manager = {}
Manager.Profiles = {}
function Manager.AdjustClicks(player: Player, amount: number)
local profile = Manager.Profiles[player]
if not profile then return end
-- Initialize clicks if nil and add amount
profile.Data.Clicks = (profile.Data.Clicks or 0) + amount
-- Update leaderstats
if player:FindFirstChild("leaderstats") then
player.leaderstats.Clicks.Value = profile.Data.Clicks
end
-- Update client GUI
local updateRemote = Remotes:FindFirstChild("UpdateClicks")
if updateRemote then
updateRemote:FireClient(player, profile.Data.Clicks)
end
end
return Manager```
does let me share the data script
*doesnt
Script - Click:
local ServerScriptService = game:GetService("ServerScriptService")
local Remotes = ReplicatedStorage.Remotes
local PlayerData = require(ServerScriptService.PlayerData.Manager)
local Cooldown = {}
local CLICK_COOLDOWN = 0.5
local function Click(player: Player)
-- Check if player is in cooldown
if table.find(Cooldown, player) then
return
end
-- Add player to cooldown
table.insert(Cooldown, player)
-- Set up cooldown removal
task.delay(CLICK_COOLDOWN, function()
local index = table.find(Cooldown, player)
if index then
table.remove(Cooldown, index)
end
end)
-- Process the click
PlayerData.AdjustClicks(player, 1)
end
Remotes.Click.OnServerEvent:Connect(Click)```
Local Script - Manager:
local Remotes = ReplicatedStorage:WaitForChild("Remotes")
local Gui = script.Parent
local Frame = Gui:WaitForChild("Frame")
local Clicks = Frame.Clicks.Amount
local Gems = Frame.Gems.Amount
local function UpdateCurrency(currency: "Clicks" | "Gems", amount: number)
if currency == "Clicks" then
Clicks.Text = tostring(amount)
elseif currency == "Gems" then
Gems.Text = tostring(amount)
end
end
Remotes:WaitForChild("UpdateClicks").OnClientEvent:Connect(function(amount)
UpdateCurrency("Clicks", amount)
end)
Remotes:WaitForChild("UpdateGems").OnClientEvent:Connect(function(amount)
UpdateCurrency("Gems", amount)
end)
** You are now Level 1! **
hmm the scripts are all over the place we cant figure it out properly
and idk where are u storing the data but please dont do it locally store everything in the server
** You are now Level 1! **
how do i do that? i was watching yt tutorial :-:
Give me a sec
Add this to the bottom of your AdjustClicks: function Manager.SetupProfile(player: Player)
Manager.Profiles[player] = {
Data = {
Clicks = 0,
Yens = 0,
Gems = 0
}
}
-- Setup leaderstats
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
stats.Parent = player
local clicks = Instance.new("IntValue")
clicks.Name = "Clicks"
clicks.Value = 0
clicks.Parent = stats
-- Sync initial GUI
local updateRemote = Remotes:FindFirstChild("UpdateClicks")
if updateRemote then
updateRemote:FireClient(player, 0)
end
end
ServerScript: local PlayerData = require(ServerScriptService.PlayerData.Manager)
game.Players.PlayerAdded:Connect(function(player)
PlayerData.SetupProfile(player)
end)
game.Players.PlayerRemoving:Connect(function(player)
PlayerData.Profiles[player] = nil
end)
add new RemoteFunction: GetPlayerData
That’s optional above
LocalScript GUI Manager: local data = Remotes:WaitForChild("GetPlayerData"):InvokeServer()
UpdateCurrency("Clicks", data.Clicks or 0)
UpdateCurrency("Gems", data.Gems or 0)
Server side:
Remotes.GetPlayerData.OnServerInvoke = function(player)
local profile = Manager.Profiles[player]
if profile then
return profile.Data
end
return { Clicks = 0, Gems = 0, Yens = 0 }
end
Check should work now
cant u just follow the tutorial more accurately
and it will work?
i did the exact same thing multiple times
it still doesnt work
Did u use the scripts I js sent
adjustclicks?
i just saw it
Ye that’s what you’re using right ?
Oh
i dont think so
u probably did something wrong earlier on then
i am doing "How to Create a Point System for a Simulator! How to Make a Simulator in Roblox Episode 3 - MonzterDev"
i think i should restart
thanks for the help @little jetty @thorn sand
If u restart try to use the scripts I sent
also following tutorials like that isnt a great idea
i dont know coding tho
sure
bruh
copying a game line for line and not actually learning is not a good idea xd