You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? A textbox selling system
What solutions have you tried so far? I’ve looked on the devfourm and nothing shows up
if tonumber(Screen.HowMuchToSell.Text) > Found[Find.Name].Amount then
Screen.HowMuchToSell.Text = math.clamp(Screen.HowMuchToSell.Text,1,Found[Find.Name].Amount)
end
-- Sell Part
local function Sell(Screen, Find, instance, CommonUI, HowMuchSelling)
Screen.Enter.MouseButton1Click:Connect(function()
Screen.Enabled = false
print(HowMuchSelling)
print(Found[Find.Name].Amount)
Found.HowMuchToSell.TextEditable = false
if tonumber(Find.PrimaryPart.Parent:GetAttribute("Amount")) or Found[Find.Name].Amount <= not 0 then
local MoneyGiven = tonumber(Find.PrimaryPart.Parent:GetAttribute("Value")) * HowMuchSelling
game.ReplicatedStorage.MoneyIncrease:FireServer(MoneyGiven,"Money")
Found[Find.Name].Amount =- HowMuchSelling
print(Found[Find.Name].Amount)
Find.PrimaryPart.Parent:SetAttribute("Amount",- HowMuchSelling)
Find.Parent.Parent.AmountLeft.Text = Found[Find.Name].Amount
if tonumber(Find.PrimaryPart.Parent:GetAttribute("Amount")) == 0 or Found[Find.Name].Amount == 0 then
instance.Parent:Destroy()
Screen.Enabled = false
Screen.HowMuchToSell.Text = "1"
Screen.HowMuchWorth.Text = "1337 C"
else
Screen.Enabled = false
Screen.HowMuchToSell.Text = "1"
Screen.HowMuchWorth.Text = "1337 C"
end
end
end)
end
Do you mean by textbox selling system that you type something a textbox and searches for the item you want to sell?
What do you mean by a textbox selling system. Please give us more detail. Thanks.
I mean like for example in a simulator you sell your bag for money but I want it where you can sell your own amount
The code works a little but it always makes the amount of “coins” in my bag -1 and I didn’t put an amount that made it go to it. Basically it spams the amount I put inside the textbox
BUILDERMANcameback:
if tonumber(Screen.HowMuchToSell.Text) > Found[Find.Name].Amount then
Screen.HowMuchToSell.Text = math.clamp(Screen.HowMuchToSell.Text,1,Found[Find.Name].Amount)
end
-- Sell Part
local function Sell(Screen, Find, instance, CommonUI, HowMuchSelling)
Screen.Enter.MouseButton1Click:Connect(function()
Screen.Enabled = false
print(HowMuchSelling)
print(Found[Find.Name].Amount)
Found.HowMuchToSell.TextEditable = false
if tonumber(Find.PrimaryPart.Parent:GetAttribute("Amount")) or Found[Find.Name].Amount <= not 1 then
local MoneyGiven = tonumber(Find.PrimaryPart.Parent:GetAttribute("Value")) * HowMuchSelling
game.ReplicatedStorage.MoneyIncrease:FireServer(MoneyGiven,"Money")
Found[Find.Name].Amount =- HowMuchSelling
print(Found[Find.Name].Amount)
Find.PrimaryPart.Parent:SetAttribute("Amount",- HowMuchSelling)
Find.Parent.Parent.AmountLeft.Text = Found[Find.Name].Amount
if tonumber(Find.PrimaryPart.Parent:GetAttribute("Amount")) == 0 or Found[Find.Name].Amount == 0 then
instance.Parent:Destroy()
Screen.Enabled = false
Screen.HowMuchToSell.Text = "1"
Screen.HowMuchWorth.Text = "1337 C"
else
Screen.Enabled = false
Screen.HowMuchToSell.Text = "1"
Screen.HowMuchWorth.Text = "1337 C"
end
end
end)
end
I’m noob at scripting but can you try that?
All your doing is changing <= 0 to <= 1, that won’t fix the spamming as it’s basically the same thing, and I tested it same problem. Thanks for trying
the amount of “coins” in my bag -1 and I didn’t put an amount that made it go to it
So basically the number became negative or something ??
Yea so basically I put a number inside a textbox pressed enter and then the amount of coins went to -
Maybe try to use math.abs.it will change the negative number to positive
Not what I’m trying to do, I’m trying to make it where it changes my bag amount - the amount I put inside the textbox, but it spams the number to make the bag amount to -
Okayyyy…so are there any error??
Nope, not a single error, everything works
Find.PrimaryPart.Parent:SetAttribute("Amount",- HowMuchSelling)
What are you trying to do here??
1 Like
o just realized that error- let me fix that
Find.PrimaryPart.Parent:SetAttribute("Amount", Find.PrimaryPart.Parent:GetAttribute("Amount") - HowMuchSelling)
if tonumber(Find.PrimaryPart.Parent:GetAttribute("Amount")) or Found[Find.Name].Amount <= not 0 then
What are you trying to do here??
It checks if Amount or the amount from the table is = or less than 0, oops forgot to get rid of not
But why there is not word if you checks if Amount or the amount from the table is = or less than 0
1 Like
Just realized that fixed that.