- already found the problem - closed

Hello, I’m wanting to make a collectable “Coin” with a shop system, the problem is, that, the shop system has a leaderboard inside of it, to get money, if I use commands, when I buy something from the shop, the money that I added disappear, for example, I give myself 1000$, I had 250 before, now I have 1250$, if I buy a weapon that has 250$ as price, when I buy it, that 1000$ disappears and my money gets to 0 (Bc the only money that was in my stats was 250), its like the system doesnt count when I add that money, same with the coins (the stats is the same as the one with commands), when I collect one, it goes to the stats, but dissapears when I buy something, same with a currency shop (same as coins and commands), I buy 100$, it gets to stats, but dissapears when I buy something, this was from a tutorial, and the only thing that gives me money and works is the system the guy made, its a block that has this script:

local DataStore2 = require(game.ServerScriptService:WaitForChild("MainModule"))
debounce = false

	if hit.Parent:FindFirstChild("Humanoid") and debounce == false then
		debounce = true
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		local MoneyData = DataStore2("Money", plr)
		debounce = false

when I touch the block, it gives me money, what I want, is to know where or how should I modify this script of my coin when I get the money:

waittime = 15 -- Time Between each hit
amnt = 30 --how much you get for it
function onTouched(part)
	local h = part.Parent:findFirstChild("Humanoid")
	if (h~=nil) then
		local thisplr = game.Players:findFirstChild(h.Parent.Name)
		if (thisplr~=nil) then
			local stats = thisplr:findFirstChild("leaderstats")
			if (stats~=nil) then
				local score = stats:findFirstChild("Money")
				if (score~=nil) then
					score.Value = score.Value + amnt
		script.Parent.Transparency = 1
		script.Disabled = true
		script.Parent.Transparency = 0
		script.Disabled = false		



If someone knows how where is the problem, please inform me. Thanks for reading

1 Like

Hey there!
Could you provide us also the module script (game.ServerScriptService.MainModule). It would be nice to provide that one, because then we can actually see, what the script, that guy from a tutorial made, does.

If you use the commands in a local script you need to use remote events, this is because I think the values have only been changed on the client so the server values are still what they were before.