You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Title
What is the issue? Include screenshots / videos if possible!
Idk how to do that + my mechanism rn isn’t working
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tryed to use while loop, but it’s too op, value go very high
My code:
local PlayersService = game:GetService("Players")
local Player = PlayersService.LocalPlayer
local PlayerGui = Player.PlayerGui
local Points = Player.leaderstats.Points
local MorePointsButton = script.Parent
local GameGUI = PlayerGui.GameGUI
local StatsFolder = GameGUI.GameFrame.PlayableFrame:WaitForChild("Stats")
local PointsMulti = StatsFolder.PointsMulti
local RebirthMulti = StatsFolder.RebirthMulti
local UpgradeCost = StatsFolder.PIUpgradeCost
local PriceMulti = 0
MorePointsButton.MouseButton1Click:Connect(function()
print("PlayerClicked!")
if Points.Value >= UpgradeCost.Value then
print("PlayerHaveEnoughPoints!")
PointsMulti.Value = PointsMulti.Value + (1 * RebirthMulti.Value)
UpgradeCost.Value = UpgradeCost.Value + ((0.5 + (RebirthMulti.Value/5)) * (PriceMulti - 1))
Points.Value = Points.Value - UpgradeCost.Value
else
print("Player Don't have enough points!")
return
end
end)
if UpgradeCost.Value >= 100 or 1000 or 10000 or 100000 or 1000000 or 10000000 or 100000000 or 1000000000 or 10000000000 then -- Value Increaser
PriceMulti = (PriceMulti + 1)* 5
wait(5)
end
local PlayersService = game:GetService("Players")
local Player = PlayersService.LocalPlayer
local PlayerGui = Player.PlayerGui
local Points = Player.leaderstats.Points
local MorePointsButton = script.Parent
local GameGUI = PlayerGui.GameGUI
local StatsFolder = GameGUI.GameFrame.PlayableFrame:WaitForChild("Stats")
local PointsMulti = StatsFolder.PointsMulti
local RebirthMulti = StatsFolder.RebirthMulti
local UpgradeCost = StatsFolder.PIUpgradeCost
local PriceMulti = 0
MorePointsButton.MouseButton1Click:Connect(function()
print("PlayerClicked!")
if Points.Value >= UpgradeCost.Value then
print("PlayerHaveEnoughPoints!")
PointsMulti.Value += (1 * RebirthMulti.Value)
UpgradeCost.Value += ((0.5 + (RebirthMulti.Value/5)) * (PriceMulti - 1))
Points.Value -= UpgradeCost.Value
else
print("Player Don't have enough points!")
return
end
end)
UpgradeCost.Changed:Connect(function()
if UpgradeCost.Value % 100 == 0 then --if number is divisible by 100
if string.match(tostring(UpgradeCost.Value), "^1[0]+$") then --if number starts with 1 and only has 0's which follow
PriceMulti = (PriceMulti + 1)* 5
wait(5)
end
end
end)
You need to wrap the checker in a “Changed” event otherwise the if conditional statement will only ever be executed once. Now whenever the value of “UpgradeCost” changes the check is performed. The check determines if the value is divisible by 100 and then ensures that the number starts with 1 and is only followed by 0’s.