Hi, I’m created a transfer money system in my game, but there’s problem. I tried to make 10% commission system, that gives you only 900 money if you pay 1000, but it gives 909.09090909…, because it divides value to 1.1 (or 1.10), so, how can I make a thing, that gives 2nd player exactly 900 money, not 909.090909…?
Can you provide the script? character limit
Perhaps change it to * 0.9
charactersss
No, but it’s working like:
Player.leaderstats.Money.Value -= tonumber(Amount)
Other.leaderstats.Money.Value += tonumber(Amount) / 1.1
Dividing by 1.1 won’t give you 10%. Divide it by 10.
local commission = math.floor(originalAmountToAdd / 10)
I’ll test it when I start making new update
theres no need for that if you can just multiply it by 0.9 and automatically get 90 percent of the number
Either method would work. I used math.floor()
to get the answer if it was a decimal - alternatively math.round()
could work.
Thanks, but that’s not working
It still giving me 909.090909… amount. (Here’s the code):
local Players = game:GetService(“Players”)
local URL = “Secret”
local HttpService = game:GetService(“HttpService”)game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(Message)
local splitMessage = string.split(Message, " ")if splitMessage[1] and string.lower(splitMessage[1]) == "/pay" then local Amount = tonumber(splitMessage[3]) or 0 if Players:FindFirstChild(splitMessage[2] or "") then local Other = Players:FindFirstChild(splitMessage[2] or "") if Player.Banned.Suspended.Value == false then if Other.Banned.Suspended.Value == false then if Other.Name == Player.Name then Player.PlayerGui.TransferUI.Message.Text = "You can't transfer money to yourself!" Player.PlayerGui.TransferUI.Message.Visible = true wait(15) Player.PlayerGui.TransferUI.Message.Visible = false else if tonumber(Amount) >= 1000 then if Player.leaderstats.Money.Value >= tonumber(Amount) then if Player.PlayerGui.TransferUI.Main.Give.Visible == true then local Commission = math.floor(tonumber(Amount) / 10) Player.leaderstats.Money.Value -= tonumber(Amount) Other.leaderstats.Money.Value += tonumber(Amount) / Commission local Data = { ["embeds"] = { { title = "New transaction by player called "..Player.Name..":", description = "Player called "..Player.Name.." just successfully gaved "..tonumber(Amount).." money to player called "..Other.Name..". Money received with commision: "..tonumber(Amount) / Commission.." . Player's ballance: "..Player.leaderstats.Money.Value..". Receiver's ballance: "..Other.leaderstats.Money.Value.."." } } } Data = HttpService:JSONEncode(Data) HttpService:PostAsync(URL, Data) Player.PlayerGui.TransferUI.Message.Text = "You successfully gaved "..tonumber(Amount).." money to player called "..splitMessage[2]..". Money count that player received (10% money cut): "..tonumber(Amount) / Commission.."." Other.PlayerGui.TransferUI.Message.Text = "Player called "..Player.Name.." just gaved you "..tonumber(Amount).." money. Current ballance: "..Other.leaderstats.Money.Value..". Money received with 10% commission: "..tonumber(Amount) / Commission.."." Player.PlayerGui.TransferUI.Main.Give.Visible = false Player.PlayerGui.TransferUI.Message.Visible = true Other.PlayerGui.TransferUI.Message.Visible = true wait(15) Player.PlayerGui.TransferUI.Main.Give.Visible = true Player.PlayerGui.TransferUI.Message.Visible = false Other.PlayerGui.TransferUI.Message.Visible = false else Player.PlayerGui.TransferUI.Message.Visible = "Transaction was unsuccessful, try again in 15 seconds." Player.PlayerGui.TransferUI.Message.Visible = true wait(15) Player.PlayerGui.TransferUI.Message.Visible = false end else if Player.leaderstats.Money.Value <= tonumber(Amount) then Player.PlayerGui.TransferUI.Message.Text = "You need "..tonumber(Amount) - Player.leaderstats.Money.Value.." more money to gave "..tonumber(Amount).." money to player called "..splitMessage[2].."!" Player.PlayerGui.TransferUI.Message.Visible = true wait(15) Player.PlayerGui.TransferUI.Message.Visible = false end end else if tonumber(Amount) <= 1000 then Player.PlayerGui.TransferUI.Message.Text = "You can't gave "..tonumber(Amount)..", because it's less than 1000." Player.PlayerGui.TransferUI.Message.Visible = true wait(15) Player.PlayerGui.TransferUI.Message.Visible = false end end end else if Other.Banned.Suspended.Value == true then Player.PlayerGui.TransferUI.Message.Text = "You tried to gave "..tonumber(Amount).." money to player called "..splitMessage[2]..", but their account has been suspended." Player.PlayerGui.TransferUI.Message.Visible = true wait(15) Player.PlayerGui.TransferUI.Message.Visible = false end end else if Player.Banned.Suspended.Value == true then local Commission = math.floor(tonumber(Amount) / 10) Player.PlayerGui.TransferUI.Message.Text = "You tried to gave "..tonumber(Amount) / Commission.." money (10% money cut) to player called "..splitMessage[2]..", but your account has been suspended." Player.PlayerGui.TransferUI.Message.Visible = true wait(15) Player.PlayerGui.TransferUI.Message.Visible = false end end else Player.PlayerGui.TransferUI.Message.Text = "Can't find player called "..splitMessage[2].." on this server." Player.PlayerGui.TransferUI.Message.Visible = true wait(15) Player.PlayerGui.TransferUI.Message.Visible = false end end
end)
end)
Would you want to subtract the commission from the amount?
Other.leaderstats.Money.Value += tonumber(Amount) - Commission
I don’t know how your code works, but in your example I think you could use something like this:
local commission = (amount / 10) * 10
Try applying the method where you multiply and divide the same numbers so its still equal to the same thing. This will make it round like how it works in a grid placement system.
I tried it, but if I try to gave other player 1000 money, it gaves 1 only
That’s strange lol, and Idk how to fix it
Should get 900 with:
local commission = math.floor(amount * 0.9)
You can add a print above that to see the amount and make sure the amount is 1000.
I don’t know how your game works but keep that method in mind because it is used for rounding.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.