#few problems with upgrade

219 messages · Page 1 of 1 (latest)

ancient ice
#

first of all, the second upgrade doesn't increase price and bonus after purchase. it also doesn't take away my fragments.

-- Upgrade 2 --
local part = workspace:WaitForChild("Board1")
local surfaceGui = part.Upgrades
local textButton = surfaceGui.Upgrade2Purchase

local plr = game:GetService("Players").LocalPlayer

local leaderboard = plr:WaitForChild("leaderstats")
local OtherFolder= plr:WaitForChild("OtherFolder")

local Event = game:GetService("ReplicatedStorage").RemoteEvent

local multiplier = OtherFolder.multiplier    
local bonus = OtherFolder.bonus

local cost2Label = surfaceGui.Upgrade2Cost    
cost2Label.Text = "Cost: "..100
local bonus2Label = surfaceGui.Upgrade2Bonus
bonus2Label.Text = "Bonus: "..1 .."% ".." > "..2 .."% " 

local numberFormatter = require(game:GetService("ReplicatedStorage").FormatNumbers)

textButton.MouseButton1Click:Connect(function(click)
    print("Clicking Upgrade 2")
    local cost = 100 * multiplier.Value
    local bonus = 1 + bonus.Value
    if leaderboard.Fragments.Value >= cost then
        Event:FireServer(cost, "upgrade2")
        wait(0.1)
        cost2Label.Text = "Cost: "..numberFormatter.format(100 * multiplier.value)
        bonus2Label.Text = "Bonus: "..1 .."% ".." > "..2 .."% "..numberFormatter.format(1 + bonus.value)
    end
end)

remote:

local RemoteEvent = game:WaitForChild("ReplicatedStorage").RemoteEvent

RemoteEvent.OnServerEvent:Connect(function(plr, cost, upgrades)
    print(cost)
    if upgrades == "upgrade1" then
        plr.leaderstats.Fragments.Value = plr.leaderstats.Fragments.Value - cost
        plr.OtherFolder.multiplier.Value *= 4
        plr.OtherFolder.bonus.Value *= 2
    elseif upgrades == "upgrade2" then
        plr.leaderstats.Fragments.Value = plr.leaderstats.Fragments.Value - cost
        plr.OtherFolder.multiplier.Value *= 10
        plr.OtherFolder.bonus.Value += 1
    end
end)    
#

few problems with upgrade

#

and second problem is, that if i have alot of fragments like 10M, and i buy first upgrade my fragments goes negative

clear latch
#

Hey

#

Does the first upgrade not work also or

pale stag
#

try using IntValues for Upgrades instead of a local variable

ancient ice
clear latch
#

Can you show both the first and second upgrade

#

so i can compare

ancient ice
#

ookay

#
-- Upgrade 1 --
local part = workspace:WaitForChild("Board1")
local surfaceGui = part.Upgrades
local textButton = surfaceGui.UpgradePurchase

local plr = game:GetService("Players").LocalPlayer

local leaderboard = plr:WaitForChild("leaderstats")
local OtherFolder= plr:WaitForChild("OtherFolder")

local Event = game:GetService("ReplicatedStorage").RemoteEvent

local multiplier = OtherFolder.multiplier    
local bonus = OtherFolder.bonus

local costLabel = surfaceGui.UpgradeCost
costLabel.Text = "Cost: "..25
local bonusLabel = surfaceGui.UpgradeBonus
bonusLabel.Text = "Bonus: x"..1 .." > x"..2

local numberFormatter = require(game:GetService("ReplicatedStorage").FormatNumbers)

textButton.MouseButton1Click:Connect(function(click)
    print("Clicking Upgrade 1")
    local cost = 25 * multiplier.Value
    local bonus = 2 * bonus.Value
    if leaderboard.Fragments.Value >= cost then
         Event:FireServer(cost, "upgrade1")
        wait(0.1)
        costLabel.Text = "Cost: "..numberFormatter.format(25 * multiplier.value)
        bonusLabel.Text = "Bonus: x"..numberFormatter.format(1 * bonus).. " > x"..numberFormatter.format(2 * bonus)
    end
end)
pale stag
#

does your output say anything?

ancient ice
#

nope.. i got no errors

clear latch
#

they look the same

#

lol

ancient ice
#

yeah

#

i compared them too

clear latch
#

maybe its a mistake in the remote

ancient ice
#

look at remote maybe? dunno

#

yeah exacly lol

#

but didn't saw anything either

clear latch
#

oh yeah btw

#

yknow your line
plr.leaderstats.Fragments.Value = plr.leaderstats.Fragments.Value - cost

#

can you just use -=

#

plr.leaderstats.Fragements.Value -= cost

ancient ice
#

oh

#

okay thanks

clear latch
#

its probably not the problem but just a suggestion

ancient ice
#

yeah, what about the problem?

clear latch
#

is upgrade 1 and upgrade 2 in the same script?

#

or are they seperate

ancient ice
#

separate

#

but in same location

clear latch
#

yeah ngl I'm looking at this and I can't find whats wrong

#

If i were you

#

I would just try and debug it

#

with something like prints

ancient ice
#

debug?

clear latch
#

see where it stops working

ancient ice
#

oh

#

but how..

#

when i press the button

#

it prints

#

where else can i check..

clear latch
#

I would probably put a print in the remote script if statements

ancient ice
#

its gonna work tho?

clear latch
#

👌

ancient ice
#

oh

clear latch
#

These upgrades

ancient ice
#
local RemoteEvent = game:WaitForChild("ReplicatedStorage").RemoteEvent

RemoteEvent.OnServerEvent:Connect(function(plr, cost, upgrades)
    print(cost)
    if upgrades == "upgrade1" then
        print("Remote activated")
        plr.leaderstats.Fragments.Value = plr.leaderstats.Fragments.Value - cost
        plr.OtherFolder.multiplier.Value *= 4
        plr.OtherFolder.bonus.Value *= 2
    elseif upgrades == "upgrade2" then
        print("Remote activated")
        plr.leaderstats.Fragments.Value = plr.leaderstats.Fragments.Value - cost
        plr.OtherFolder.multiplier.Value *= 10
        plr.OtherFolder.bonus.Value += 1
    end
end)    
#

doesnt print..

clear latch
#

oh really

ancient ice
#

hm

#

so the problem

clear latch
#

in that case, you might have a type in the arguements?

ancient ice
#

has to be here

    Event:FireServer(cost, "upgrade2")
#

yes?

ancient ice
#

well.. all seems to be correct

clear latch
#

yeah all does seem correct

#

still

#

so im still kinda stumped

ancient ice
#

hmm

#

the first upgrade works

#

the second doesn't

#

it just dosnt substract cost

#

and doesnt add bonus

#

lets think why?

clear latch
#

quick question

#

does it print different costs

ancient ice
#

the second upgrade?

clear latch
#

in the remote I see you have print(cost)

#

is it printing the different costs

ancient ice
#

yeah

#

in first upgrade

clear latch
#

ok

ancient ice
#

wait

#

wth

#

the remote print works now

#

for no reason it startd to work

clear latch
#

huh

#

like it fixed?

ancient ice
#

no no

#

but the remote print works

#

for first upgrade

clear latch
#

oh

#

ok ok

ancient ice
#

it wasnt

clear latch
#

huh

#

it wasnt for the first?

ancient ice
#

wait

#

or it was

#

ok nvm lol

clear latch
#

oh yeah could you post the current script

#

just wanna make sure im seeing the same thing as you

ancient ice
#

which?

clear latch
#

uuhhh

#

i guess all three would be fine

ancient ice
#

alr

#
-- Upgrade 1 --
local part = workspace:WaitForChild("Board1")
local surfaceGui = part.Upgrades
local textButton = surfaceGui.UpgradePurchase

local plr = game:GetService("Players").LocalPlayer

local leaderboard = plr:WaitForChild("leaderstats")
local OtherFolder= plr:WaitForChild("OtherFolder")

local Event = game:GetService("ReplicatedStorage").RemoteEvent

local multiplier = OtherFolder.multiplier    
local bonus = OtherFolder.bonus

local costLabel = surfaceGui.UpgradeCost
costLabel.Text = "Cost: "..25
local bonusLabel = surfaceGui.UpgradeBonus
bonusLabel.Text = "Bonus: x"..1 .." > x"..2

local numberFormatter = require(game:GetService("ReplicatedStorage").FormatNumbers)

textButton.MouseButton1Click:Connect(function(click)
    print("Clicking Upgrade 1")
    local cost = 25 * multiplier.Value
    local bonus = 2 * bonus.Value
    if leaderboard.Fragments.Value >= cost then
         Event:FireServer(cost, "upgrade1")
        wait(0.1)
        costLabel.Text = "Cost: "..numberFormatter.format(25 * multiplier.value)
        bonusLabel.Text = "Bonus: x"..numberFormatter.format(1 * bonus).. " > x"..numberFormatter.format(2 * bonus)
    end
end)
#

upgrade 1

#
-- Upgrade 2 --
local part = workspace:WaitForChild("Board1")
local surfaceGui = part.Upgrades
local textButton = surfaceGui.Upgrade2Purchase

local plr = game:GetService("Players").LocalPlayer

local leaderboard = plr:WaitForChild("leaderstats")
local OtherFolder= plr:WaitForChild("OtherFolder")

local Event = game:GetService("ReplicatedStorage").RemoteEvent

local multiplier = OtherFolder.multiplier    
local bonus = OtherFolder.bonus

local cost2Label = surfaceGui.Upgrade2Cost    
cost2Label.Text = "Cost: "..100
local bonus2Label = surfaceGui.Upgrade2Bonus
bonus2Label.Text = "Bonus: "..1 .."% ".." > "..2 .."% " 

local numberFormatter = require(game:GetService("ReplicatedStorage").FormatNumbers)

textButton.MouseButton1Click:Connect(function(click)
    print("Clicking Upgrade 2")
    local cost = 100 * multiplier.Value
    local bonus = 1 + bonus.Value
    if leaderboard.Fragments.Value >= cost then
        Event:FireServer(cost, "upgrade2")
        wait(0.1)
        cost2Label.Text = "Cost: "..numberFormatter.format(100 * multiplier.value)
        bonus2Label.Text = "Bonus: "..1 .."% ".." > "..2 .."% "..numberFormatter.format(1 + bonus.value)
    end
end)
#

upgrade 2

#
local RemoteEvent = game:WaitForChild("ReplicatedStorage").RemoteEvent

RemoteEvent.OnServerEvent:Connect(function(plr, cost, upgrades)
    print(cost)
    if upgrades == "upgrade1" then
        print("Remote activated")
        plr.leaderstats.Fragments.Value = plr.leaderstats.Fragments.Value - cost
        plr.OtherFolder.multiplier.Value *= 4
        plr.OtherFolder.bonus.Value *= 2
    elseif upgrades == "upgrade2" then
        print("Remote 2 activated")
        plr.leaderstats.Fragments.Value = plr.leaderstats.Fragments.Value - cost
        plr.OtherFolder.multiplier.Value *= 10
        plr.OtherFolder.bonus.Value += 1
    end
end)    
#

remote

clear latch
#

ty

#

is plr.OtherFolder meant to be the same?

ancient ice
#

where?

#

in remote

#

?

clear latch
#

yeep

ancient ice
#

wdym the same

clear latch
#

both upgrades 1 and 2 change plr.OtherFolder

ancient ice
#

ooh..

#

how do i fix that then..

#

i dont want more values in leaderstat

clear latch
#

Im assuming the upgrades are meant to buff 2 different stats or whatever

#

right?

ancient ice
#

yeah

#

right now

clear latch
#

Ok

ancient ice
#

there is a button which gives base +1 fragment per click

#

and it doubles on purchase

#

and there are clicks

#

which are 1/100 to drop from clicking the button

#

and i want to make the odds lower by 1 with each upgrade

clear latch
#

uhhhh

#

ok

#

wait did you ever mention this before

#

cause this is some new info im gettin

#

lol

ancient ice
#

no

#

i did not

#

but its not something i added now

clear latch
#

ok

#

i feel like you have to make another stat but you dont want that

#

right

ancient ice
#

yeah

clear latch
#

theres probably another solution

ancient ice
#

i would like to make everything based on multiplier if possible

ancient ice
#

if i had to make new stat for every upgrade there would be like 1000 lines of code

clear latch
#

oof

#

that would suck

ancient ice
#

yea

#

very lol

#

imagine rebalancing the game then

clear latch
#

reminds me of another game

ancient ice
#

what game?

clear latch
#

forgot what it was but they had to remake the whole game because they missed one thing

#

crazy am i right

ancient ice
#

your game?

clear latch
#

no

#

not mine

ancient ice
#

ah

clear latch
#

its just something i heard of

#

anyway

#

back to the problem

ancient ice
#

yep

clear latch
#

you said it only doesnt change the player's multiplier, fragments, and bonus right

#

yes, no?

ancient ice
#

idk what u mean by that

#

it basicly

clear latch
#

basically the remote event for upgrade 2 dont work

ancient ice
#
  • doesnt substract fragments on purchase
  • doesnt increase price
  • doesnt increase bonus
clear latch
ancient ice
#

there is no multiplier

#

oh i mean

#

there is for cost

#

mb

clear latch
#

this thingymabob

ancient ice
#

yeah its price, my baf

#

bad*

clear latch
#

ah ok ok ok

gloomy mauveBOT
#

studio** You are now Level 11! **studio

clear latch
ancient ice
#

what prints

clear latch
#

the prints in both upgrade2 script and remote script

ancient ice
#

the print in upgrade script works

clear latch
ancient ice
#

but in remote doesnt

clear latch
#

oki

ancient ice
#

yea the clicking upgrade 2 prints

clear latch
#

i just feel like the

 Event:FireServer(cost, "upgrade2")
#

is the problem

#

but at the same time

ancient ice
#

me too but idk what

clear latch
#

it doesn't look like its wrong at all

ancient ice
#
local Event = game:GetService("ReplicatedStorage").RemoteEvent
#

idk

clear latch
#

the local Event is the same in both

#

so i dont see why

#

it wouldnt do anything

ancient ice
#

wait

#

shoud it say .RemoteEvent

#

if the remote is called RemoteReciever?

clear latch
#

oh

#

probably not

#

lol

ancient ice
#

ah'

clear latch
#

tell me if anything changed after you rename it

ancient ice
#

nope..

#

thats so

#

brain-melting

ancient ice
#

💀

#

i just wish there was an error

clear latch
#

same bruh 😭

ancient ice
#

cant

#

ima try to fix it tmr

#

lol 212 messages..

clear latch
#

gl bro

ancient ice
#

ty

#

thats such a hell

#

such a simple thing..

#

i mean i think i could fix that but i want it to be in one remote..

#

not in 2 functions