How to make an equation to pay players 0.2 coins a second

I am making a system where if players own a building they get 0.2 coins a second. This alone would be easy to make however you can make upgrades to this building to make 0.4 coins a second, 0.6 coins a second ect… you can also purchase more than one building so there is pretty much no limit on how much you can be earning a second. I made a number value inside player scripts called “Coins” and another one called “CoinsPerSecond”. I don’t know where to start does anyone have an idea?

Create a folder in ReplicatedStorage called Buildings and attach PlayerAdded event to a script which would create a new folder, name it player’s name and parent it to the Buildings folder:

-- Script in ServerScriptService

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Buildings = ReplicatedStorage:WaitForChild("Buildings")

Players.PlayerAdded:Connect(function(Player: Player)
    local playerBuildings = Instance.new("Folder")
    playerBuildings.Name = Player.Name
    playerBuildings.Parent = Buildings
end)

Players.PlayerRemoving:Connect(function(Player: Player)
    local playerBuildings = Buildings:FindFirstChild(Player.Name)
    if playerBuildings then
        playerBuildings:Destroy()
    end
end)

Later you can create int values called Building0, Building1, Building,2 etc. and they can contain buildings level or whatever that can determine how much cash per second it gives.

This is my gamemode which has a couple of different scripts inside of it.

local ReplicatedStorage = game:GetService(“ReplicatedStorage”) local PlayerScripts = ReplicatedStorage:WaitForChild(“PlayerScripts”) local PlayerScriptsFolder = PlayerScripts:WaitForChild(“PlayerScriptsFolder”) local PlayerScript = PlayerScriptsFolder:WaitForChild(“PlayerScript”) local PlayerScript2 = PlayerScriptsFolder:WaitForChild(“PlayerScript2”) PlayerScripts.DescendantAdded:Connect(function(Child) Child.Changed:Connect(function() PlayerScriptsFolder.ChildAdded:Connect(function(player) local PlayerScriptClone = PlayerScript:Clone() PlayerScriptClone.Parent = player PlayerScriptClone.Disabled = false end) end) Child.ChildAdded:Connect(function(player) local PlayerScriptClone = PlayerScript:Clone() PlayerScriptClone.Parent = player PlayerScriptClone.Disabled = false end) local PlayerScriptClone = PlayerScript:Clone() PlayerScript.Parent = Child PlayerScript.Disabled = false end) PlayerScripts.ChildAdded:Connect(function(Child) child.Changed:Connect(function() local PlayerScriptClone = PlayerScript:Clone() PlayerScriptClone.Parent = Child PlayerScriptClone.Disabled = false end) end) ReplicatedStorage.DescendantAdded:Connect(function(Child) Child.Changed:Connect(function() ReplicatedStorage.ChildAdded:Connect(function(player) local PlayerScriptClone = PlayerScript:Clone() PlayerScriptClone.Parent = player PlayerScriptClone.Disabled = false end) end) Child.ChildAdded:Connect(function(player) local PlayerScriptClone = PlayerScript:Clone() PlayerScriptClone.Parent = player PlayerScriptClone.Disabled = false end) end) ReplicatedStorage.ChildAdded:Connect(function(Child) Child.Changed:Connect(function() local PlayerScriptClone = PlayerScript:Clone() PlayerScriptClone.Parent = Child PlayerScriptClone.Disabled = false end) end)

This is my player script where the number values are located and where I need the equation