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

Upgrader wont upgrade ores...? HUH?

Asked by 3 years ago

I copied an upgrader script and changed the script accordingly. But the ores cash value won't get multiplied by 2 or even 999999999999999, whatever. It should work since I literally copied it from a working upgrader but it doesn't?

1script.Parent.Upgrader.Touched:Connect(function(Part)
2 
3    if Part:FindFirstChild("Cash") then
4        Part.Cash.Value = Part.Cash.Value * 2
5    end
6 
7end)

Just typical upgrader script ^

(This is Zednov's Tycoon Kit, so test it out.) No, it's not a local script, yes, the ore is touching the upgrader.

0
Fixed it... Had to make the upgrader bigger in the Y? #roblox-broken Krektonix_Youtube 85 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago

Fixed it... Had to make the upgrader bigger in the Y? #roblox-broken

Ad
Log in to vote
0
Answered by
Antelear 185
3 years ago
Edited 3 years ago

I suggest making an attribute in the part so we can fetch the value there.

01local db = false -- db means like a cooldown. so it doesn't double over and over.
02 
03script.Parent.Upgrader.Touched:Connect(function(Part)
04    if Part:IsA("Part") then -- if it's anything else (player), then we don't want it to run.
05        if db then return end -- if db is true then we don't want it to run, so if it's true then return nil
06        db = true
07        local Att = Part:GetAttribute("Cash").Value -- go to the part, go to its properties and scroll down to "Add Attribute", click add, make it a number, and make it the number you want it to (don't forget to give it a name for example "Cash"). Then make this line to fetch the attribute's value.
08        Att = Att*2 --(you can do an extra bit of coding to make the bank add the cash by retrieving the part's attribute).
09    end
10end)

script.Parent.Upgrader.TouchEnded:Connect(function() db = false -- this is to make sure it can continue being upgraded once it stops touching the upgrader. end)

I hope this helps!

Answer this question