Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Struggling to find bug in my script from my clicker game?

Asked by 1 year ago

So I have been making this game and I'm trying to add an upgrading system. But the script that meant to be the automated stuff your making isn't working with the rework. The goal here is to combine the number of buildings you have by the multiplier from the upgrade. There is no error in the console. This script is a server script which is located in ServerScriptService. The hi's do print but the Chocolate leaderstat does not rise. Script:

local NOMC = game.Workspace.MCbutton.Top.Script.NOMC
local NOB = game.Workspace.Bbutton.Top.Script.NOB
local NOC = game.Workspace.Cbutton.Top.Script.NOC
local MCmulti = NOMC.Parent.MCmulti
local Bmulti = NOB.Parent.Bmulti
local Cmulti = NOC.Parent.Cmulti
local MC = NOMC.Value * 1 * MCmulti.Value
local B = NOB.Value * 5 * Bmulti.Value
local C = NOC.Value * 25 * Cmulti.Value

game.Players.PlayerAdded:Connect(function(player)
    while true do
        player:WaitForChild("leaderstats").CPS.Value = MC + B + C
        if player.leaderstats.CPS.Value >= 20 then
            print("hi")
            player.leaderstats.Chocolate.Value += player.leaderstats.CPS.Value / 20
            print("hi")
            wait(0.05)
        else
            print("hi")
            player.leaderstats.Chocolate.Value += player.leaderstats.CPS.Value
            print("hi")
            wait(1)
        end
    end
end)

1 answer

Log in to vote
1
Answered by 1 year ago

I have figured it out! Finally! I had to set some of the values inside of the while true do and now it works flawlessly! Thanks me!

Ad

Answer this question