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)
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