What do you want to achieve? Keep it simple and clear!
I wanna achieve, when i touch button i buy someth in my tycoon.
What is the issue? Include screenshots / videos if possible!
Issue is: when im using button my roblox studio just lags very huge, and sometimes crash and if i make an upgrade it give double value to upgrade value, i think this is cause i touch it by legs and i touch it infinite. Note: I tryed to make button non-collision and invisible, but it’s just no works idk why. Here is some screenshots:
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tryed to make script for transparency of button & non-collide, but it’s don’t work + even if it will work 2 parts will still touch button, and i need only one part of player touch button. Idk if that possible to find that on devhub/youtube
Add a debounce so that the event doesn’t fire multiple times.
local debounce = true
-- event
if debounce then
debounce = false
-- script
debounce = true
end
If you use a debounce you can also make it so that a single event is used for all buttons and you can store a bought value in a module or datastore. i.e
Okay nevermind i fixed upgrade button, just made it without can touch when i touch it. But buy button script still lags my roblox huge, and don’t become invisible, non-collide, non-touch
local db = false
--Upgrade button script
local SpeedLevel = script.Parent.Parent.SpeedLevel
script.Parent.Touched:Connect(function()
if SpeedLevel.Value == 0 then
if not db then
db = true
SpeedLevel.Value = SpeedLevel.Value + 1
script.Parent:Destory()
wait(10)
db = false
end
end
end)