first code: Location : part script type : script
script.Parent.ClickDetector.MouseClick:Connect(function(player) player.leaderstats.Crops.Value = player.leaderstats.Crops.Value + 2 end)
outcome : Player.Leaderstats.Crops.Value = 2
second code: Location : tool Script type : Local Script
script.Parent.Equipped:Connect(function(Mouse) Mouse.Button1Down:Connect(function() player.leaderstats.Crops.Value = player.leaderstats.Crops.Value - 1 end) end)
outcome : Player.Leaderstats.Crops.Value = 1
but when I clicked the part that has my first code again , the oucome is 4 instead of 3 How do I fix this , plz help me
Part of your code is running on the server, and part of your code is running on the client. The client is not allowed to make changes directly to the server, so anything a local script does will not be seen by your server script. Remote events will be necessary in order for the tool to be able to make changes for the int value.
More literature is available about the Client-Server Model and using Remote Events/Functions on the developer website.
The developer wiki will be your best friend as you learn to script.