data store and selling currency ONLY comes from the server side not the client
Could you show the code? That will help people understand your problem.
please how us the code so we can help you
fe update was a very long time ago tbh. also datastore on client doesnt work. You can’t write datastore on the client do to fe (as you said).
ye and the selling doesn’t work when im on the client side
is this due to a filtering enabled update
code 1:
local part = script.Parent
local db = true
part.Touched:Connect(function(hit)
if hit.Parent and hit.Parent:FindFirstChild(“Humanoid”) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
local stats = plr.leaderstats
local c1 = stats.Clicks
local c2 = stats.Coins
if c1.Value > 0 then
if db == true then
c2.Value = c2.Value +c1.Value*1
db = false
wait(1)
db = true
end
end
end
end
end)
idk how to post lua code like it is in rs
code 2: (used tech with mike’s code)
local DataStoreService = game:GetService(“DataStoreService”)
local playerData = DataStoreService:GetDataStore(“PlayerData”)
local function onPlayerJoin(player) – Runs when players join
local leaderstats = Instance.new(“Folder”) --Sets up leaderstats folder
leaderstats.Name = “leaderstats”
leaderstats.Parent = player
local c = Instance.new("IntValue") --Sets up value for leaderstats
c.Name = "Clicks"
c.Parent = leaderstats
local Co = Instance.new("IntValue")
Co.Name = "Coins"
Co.Parent = leaderstats
local r = Instance.new("IntValue") --Sets up value for leaderstats
r.Name = "Rebirths"
r.Parent = leaderstats
local CB = Instance.new("IntValue")
CB.Name = "Click Backpack"
CB.Parent = leaderstats
local playerUserId = "Player_" .. player.UserId --Gets player ID
local data = playerData:GetAsync(playerUserId) --Checks if player has stored data
if data then
c.Value = data['Clicks']
Co.Value = data['Coins']
r.Value = data['Rebirths']
CB.Value = data['Click Backpack']
else
-- Data store is working, but no current data for this player
c.Value = 0
Co.Value = 0
r.Value = 0
CB.Value = 10
end
end
local function create_table(player)
local player_stats = {}
for _, stat in pairs(player.leaderstats:GetChildren()) do
player_stats[stat.Name] = stat.Value
end
return player_stats
end
local function onPlayerExit(player) --Runs when players exit
local player_stats = create_table(player)
local success, err = pcall(function()
local playerUserId = "Player_" .. player.UserId
playerData:SetAsync(playerUserId, player_stats) --Saves player data
end)
if not success then
warn('Could not save data!')
end
end
game.Players.PlayerAdded:Connect(onPlayerJoin)
game.Players.PlayerRemoving:Connect(onPlayerExit)
I’ve been trying to work on a project and still does the same, I made a bindable event and fired it using the
:Fire “function”
Now it only works for a little then stops what it’s doing
credit to boxyplays for this
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
player = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.Sell:Fire(player)
end
end)