I’m making a simple civilization-rp type game, similar to GRG or Thy Hood
I wanted to make a tax rate system, so any money that the player earns goes through a % tax, and they earn the inverse %. So if they were to make $2, and the tax rate is 50%, they are only given $1.
Problem is i am really confused on how i actually implement this, its incredibly confusing.
Im using a tax rate int value in replicated storage, and the player’s money is added to their leaderstats after performing an action which gives them money like chopping trees, harvesting crops, etc.
^ not really sure if some of that was necessary, but whatever
local Players = game:GetService("Players")
local function onAxeTouch(otherPart)
local log = otherPart.Parent:FindFirstChild("treedetect")
local treeHealth = log and log:FindFirstChild("TreeHealth")
local profit = log:FindFirstChild("Profit")
local taxrate = game.ReplicatedStorage.TaxRateValue.Value
local moneytogive = profit - (profit*taxrate)
if treeHealth then
treeHealth.Value = treeHealth.Value - 1
if treeHealth.Value <= 0 then
local player = Players:GetPlayerFromCharacter(otherPart.Parent)
if player then
local leaderstats = player:FindFirstChild("leaderstats")
local cash = leaderstats and leaderstats:FindFirstChild("Cash")
if cash then
cash.Value = cash.Value + moneytogive
end
end
end
end
end
local function setupAxe(axe)
local handle = axe:FindFirstChild("Handle")
if handle then
handle.Touched:Connect(onAxeTouch)
end
end
ive got this code at the moment, trying to use what you suggested;
it does still work by adding the profit you’re meant to get, but it doesnt multiply the amount or anything
the value of profit is 2, and the value of taxrate is 25
i mean thatd probably make the amount something like 50?? but i just wanted to see a result thatd sort of work
i mean, if i can get this to work at all im still not really sure how im going to get the money into the ruler’s bank or how to make it multiply correctly
I’m a little confused on what the problem is here now, so your moneytogive should be 2 - (2*25) which would be 2 - 50 or -48, but you mentioned that it’s not multiplying the value, so moneytogive is just 2?
My head hurts lol
maybe your using an integer vale. An Integer is any Whole Number on both the negative and positive sides of 0.
Just change the value to a Number Value which will let you have any type of number, including rational/irrational (math.round() is a very helpful tool), integer, whole.