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

How to make the ore only upgrade once instead of multiply times?

Asked by 6 years ago

So, I have a script the looks for a StringValue named "Tags" and if the Tags is = 0 then it will upgrade the ore once. Well, that is what I thought, but it still does upgrades the ore more than once. How do I change the script so that it will always look for the "Tags" value before upgrading the ore? Any help will be appreciated! Thanks. <3

wait(0.01)
script.Parent.Upgrade.Touched:connect(function(hit)
    if hit:FindFirstChild("Cash","Tags" == 0 )  then
        hit.Tags.Value = hit.Tags.Value + 1
        hit.Cash.Value = hit.Cash.Value + 2
    end
end)

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Remove the

hit.Tags.Value = hit.Tags.Value + 1

completely. Let's say Cash.Value before touching the upgrader is 5. On touch, Cash.Value will be 7. So, maybe you could use something like:

wait(0.01)
script.Parent.Upgrade.Touched:connect(function(hit)
    if hit:FindFirstChild("Cash" == 7 )  then --check if part already touched upgrader
print("Part already touched.") --if it did, print the message
else
        hit.Cash.Value = hit.Cash.Value + 2 --it did not touch, so now we make it worth more.
    end
end)

I'm not 100% sure if this will work, but you could certainly give it a try. I would give an explanation to why I think this would work, but it should be obvious.

(before posting edit: i added some comments to the actual script showing why)

If I helped, please remember to upvote! -Doge Master

0
 I see where you are coming from as when the ore value is worth ‘$7’, it would upgrade it and that’s assuming we have a ore that is worth ‘$7’, what if the ore value isn’t worth ‘$7’? It wouldn’t upgrade the ore unless it is worth exactly ‘$7’.What my idea is the upgrader will look for this thing named ‘ore’. When the ore hits the upgrader, the name will be changed to ‘ore2’ meaning it would not b XviperIink 428 — 6y
Ad

Answer this question