I want to try making an upgraded that will increase the upgrade amount every time the player presses the button
so the code that upgrades the ore won’t update when the value is changed
I’ve tried using intValue.changed and also searched the web for help
local value = script.Parent.Value.Value --the value is a intvalue
script.Parent.Upgrader.Touched:connect(function(Part)
if Part:FindFirstChild("Cash") then
print(value)
end
end)
--Part.Cash.Value = Part.Cash.Value + value
Yes, :connect() is deprecated; along with other methods such as :wait()
local value = script.Parent:FindFirstChild("Value")
local debounce = false
script.Parent.Upgrader.Touched:Connect(function(hit)
if debounce == false then
debounce = true
if hit:FindFirstChild("Cash") then
hit.Cash.Value = hit.Cash.Value + value.Value
end
wait(1)
debounce = false
end
end)
Maybe that those objects don’t exist. I also added a debounce for 1 second so everything doesn’t go crazy. So pretty be sure all of your objects actually exist.
Deprecated functions may be removed in the future or have unpredictable behavior. This is why it is good practice.
Though, sometimes they’re just deprecated in favor of a more updated or newer or cleaner version I believe like how raycastparams replaced the ray object casting. :connect is deprecated in favor of PascalCase when Roblox didn’t use PascalCase at the time.