i need to make it so when i chop a tree its adds 15 "Lumber" to the leaderboard? Thanks, TSSRafa.
All you have to do is add a line of code that increase the value of "Lumber" to your tree chopper script when it chopped a tree
example line of code
player.leaderstats.Lumber.Value = player.leaderstats.Lumber.Value + 15
Hello! You will need a RemoteEvent in Replicated Storage called "GiveLumber" (name it whatever). Inside the local script for the axe, you will first need to define the remote.
local lumber_remote = game:GetService("ReplicatedStorage").GiveLumber
Next, "tell" the remote to activate by doing the following (this goes inside your Axe local script):
local lumber_amount = 15 lumber_remote:FireServer(lumber_amount)
Then, you need to make a normal Script and place it in ServerScriptService. (you can name it to your liking)
Inside that script, you will need to define the remote again and add the leaderstat value, here's how! (This goes inside your new Script placed in ServerScriptService)
local lumber_remote = game:GetService("ReplicatedStorage").GiveLumber lumber_remote.OnServerEvent:Connect(function(player, amount) player.leaderstats.Lumber.Value = player.leaderstats.Lumber.Value + amount end)
To explain what happens inside the Server Script, when you activate a remote through a local script, the Player parameter is already defined for you, therefore you don't have to send it through the local script, all you have to do is define it within the "function([plr])" part. Since we sent the "lumber_amount" through the ":FireServer" part, that will be an item that you can "grab" from the local script and be able to read.
There you have it! For future reference, you need to use Remotes to send local data to the server since local scripts are only client-based. Hope this helps!
If you need help with Remotes, here is the Developer Wiki link: https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events