if you wanna SAVE IT in DSS than you should try this instead
local Datastore = game:GetService("DataStoreService"):GetDataStore("Wood")
script.Parent.Triggered:Connect(function(plr)
local Wood = DataStore:GetAsync(plr.Name)
if not Wood then
DataStore:SetAsync(plr.Name,0)
end
plr.leaderstats.Wood.Value += 1
DataStore:SetAsync(plr.Name,Wood+1)
script.Parent.Parent.Parent:Destroy()
end)
This will save it.
To load it when the player joins you should INSERT THIS in your leaderstats script
--...Your script
-- PLAYER = your player variable at .PlayerAdded- Change it to that
-- WOODVALUE = your leaderstats.Wood value variable- Change it to that
local DSS = game:GetService("DataStoreService")
local WoodStore = DSS:GetDataStore("Wood")
if not WoodStore:GetAsync(PLAYER.Name) then
WoodStore:SetAsync(PLAYER.Name,0)
end
WOODVALUE.Value = WoodStore:GetAsync(PLAYER.Name)
--...Your script