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?
1 | script.Parent.Upgrader.Touched:Connect( function (Part) |
2 |
3 | if Part:FindFirstChild( "Cash" ) then |
4 | Part.Cash.Value = Part.Cash.Value * 2 |
5 | end |
6 |
7 | end ) |
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.
Fixed it... Had to make the upgrader bigger in the Y? #roblox-broken
I suggest making an attribute in the part so we can fetch the value there.
01 | local db = false -- db means like a cooldown. so it doesn't double over and over. |
02 |
03 | script.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 |
10 | end ) |
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!