Accsesing value inside playerGui

so I’m trying to make it so when a player clicks the button it will minus the item by one but i can’t seem to accses the value so i can’t do - 1. This is the script that firses the server.

local itemsScrollingFrame = script.Parent
local mouse = game:GetService("Mouse")
local itemHandler = game:GetService("ReplicatedStorage"):WaitForChild("ItemHandler")

local player = game.Players.LocalPlayer
local leaderstats = player:WaitForChild("leaderstats")
local money = leaderstats:WaitForChild("Money")

for index, item in pairs(itemsScrollingFrame:GetChildren()) do
	if item.ClassName == "TextButton" then
		local sellButton = item:FindFirstChild("SellButton")
		sellButton.MouseButton1Up:Connect(function()
			local amountItem = item.AmountItem
			itemHandler:FireServer(item, money, amountItem.Value)
		end)
	end
end

and this is the script that gets the signal

local itemHandler = game:GetService("ReplicatedStorage"):WaitForChild("ItemHandler")

itemHandler.OnServerEvent:Connect(function(player, item, money, amountItem)
	if item.Name == "Rock" then
		local amountMinus = amountItem
		print(item.AmountItem.Value)
		amountItem -= 1
		local numberGetting = math.random(1,3)
		if numberGetting == 1 then
			money.Value += 0.01
		elseif numberGetting == 2 then
			money.Value += 0.02
		elseif numberGetting == 3 then
			money.Value += 0.03
		end
       end
end)

can someone pelase help me with this?

1 Like

I’m sorry but I don’t recall, “Mouse” being a valid service

thom is right, use game.Players.LocalPlayer:GetMouse()

what? do you mean_____________

mouse variable isnt being used anywhere in the script so i’m sure the author can remove the line entirely

sure but it doesnt solve the problem

Are there any errors in the output?

no when i print the number of the value it says 0

amountVlaue does print the rigth number

but I can - it whit the value i dont know how

Hmm tell me this, is the value an IntValue, or a NumberValue?

numbervalue_______________wwwww

Try doing this

amountitem = amountitem - 1

below the “print” line, isn’t it supposed to be:

item.AmountItem.Value -= 1

I accsedentely left it there_________

doesnt work too_________________

No no i mean, replace

amountItem -=1

with

item.AmountItem.Value -= 1

ive already tried that________

maybe its goign wrong at the part where i sent the value to the server or something

Was the button created by a LocalScript?