Attempt to call a userdata value, i dont know what this means, im on a script, not a local script, here is my code
script.Parent.MouseButton1Click:Connect(function()
local toolname = script.Parent.Parent.Itemname.Text
local cost = script.Parent.Parent.Price.TextLabel.Text
local tool = game.ReplicatedStorage(toolname)
local money = script.Parent.Parent.Parent.Parent.Parent.Parent
if money <= tonumber(cost) then
money = money - cost
local tool = tool:Clone()
tool.Parent = game.Players.LocalPlayer.Backpack
end
end)

3 comments
Wait a second, wouldn't we only deduct from the money variable if the amount of money we have is greater than or equal to the cost? If it's less than the cost, then we shouldn't be able to purchase the item.
Also, if money is an instance(given how he references it with the variable it probably is), then wouldn't we deduct from its value property and not the entire instance? Seems kind of odd to me. I know this is an answer and not written by the guy who asked the question, but yeah.
Oh, I'll fix that.