as the title said, leaderstats won't update properly, here are some screenshots of that what's happening

https://i.imgur.com/JQWQ49e.png / https://imgur.com/JQWQ49e

and that's the code for selling

local part = script.Parent
part.Touched:Connect(function(hit)
	local h = hit.Parent:FindFirstChild("Humanoid")
	if h then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
   if player then
	  local leaderstats = player:WaitForChild("leaderstats")
	  local money = leaderstats.Cash
	  local selling = leaderstats.Bricks
		if selling.Value >= 0 then
		  money.Value = money.Value + selling.Value*1
		  selling.Value = 0
		end
	end
	end
end)

and for buying

local player = game.Players.LocalPlayer

script.Parent.MouseButton1Click:Connect(function(click)
	if player.leaderstats.Cash.Value >= 50 then 
		player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - 50 

		game.ReplicatedStorage.Tools.Brick1:Clone().Parent = player:WaitForChild("Backpack") 
	end
end)

I hope someone knows what's going on

2 comments

0

Ur buying script is good but ur selling script is wrong, Touched is not an valid member of serverscriptserver, i hoped this helped

0

Do you think using a function instead would solve the problem?