I've been making a sort-of mc uhc clone for the past week, and I've suddenly hit a roadblock with making the "crafting" system, which is essentially a shop. Here's my code inside the button:

local button = script.Parent
local toggled = false
x = script.Parent
plr = game.Players.LocalPlayer
print("Gui: "..plr.Name) --test the player's name
local function onButtonActivated()
	print("Wood: "..plr:FindFirstChild("Backpack"):FindFirstChild("Inventory"):FindFirstChild("Wood").Value) --test for the wood count (with both check strategies)
	print("Wood (different check): "..plr.Backpack.Inventory.Wood.Value)
	if plr.Backpack.Inventory.Wood.Value >= 2 then
		plr.Backpack.Inventory.Wood.Value = plr.Backpack.Inventory.Wood.Value - 2
		plr.Backpack.Inventory.Stick.Value = plr.Backpack.Inventory.Stick.Value + 1
		print("Bought")
	end
	wait(0.1)
end

button.Activated:Connect(onButtonActivated)

The UI or the player's global statistic isn't updating. I used the first 2 print commands to test the value, and it works just fine in those regards.

1 comment

0

With a LocalScript, you're only updating the value locally. You need to use a remote event and have the server change it. Changing it on the client(the player) will only show for the client. Changing it on the server will show for the server and all clients.