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)