Problem with buying someth in my tycoon

  1. What do you want to achieve? Keep it simple and clear!
    I wanna achieve, when i touch button i buy someth in my tycoon.

  2. 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:


  3. 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

Here is scripts:

--Buy button script

script.Parent.Touched:Connect(function()
	local Factory = game.ServerStorage.Model:Clone()
Factory.Parent = workspace
	Factory:MakeJoints()
	script.Parent.CanCollide = false
		script.Parent.Transparency = 1
	end)

--Upgrade button script
local SpeedLevel = script.Parent.Parent.SpeedLevel
if SpeedLevel.Value == 0 then
script.Parent.Touched:Connect(function()
		SpeedLevel.Value = SpeedLevel.Value + 1
		script.Parent.CanCollide = false
		script.Parent.Transparency = 1
	end)
	end
--Upgrade button script
local SpeedLevel = script.Parent.Parent.SpeedLevel
if SpeedLevel.Value == 0 then
script.Parent.Touched:Connect(function()
		SpeedLevel.Value = SpeedLevel.Value + 1
		script.Parent.CanTouch = false
		script.Parent.Transparency = 1
	end)
	end

Would Do It Just Changed CanCollide To CanTouch

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

if module.item1.bought == false then

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

Well Yes But You Can Also Use :Destory() Or CanTouch = false

Um i didn’t understand a bit hmm

CanTouch didn’t help, i tryed that

:Destroy() Would Help I Guess Cause In Tycoons The Button Disappears|

Like This

--Upgrade button script
local SpeedLevel = script.Parent.Parent.SpeedLevel
if SpeedLevel.Value == 0 then
script.Parent.Touched:Connect(function()
		SpeedLevel.Value = SpeedLevel.Value + 1
                script.Parent:Destroy()
	end)
	end
  • Idk why but i can’t use non-collide or non-touch or transparency on buy button, on upgrade button everyth works fine

This Is Cause non-collide and transparent Dont Stop It From Triggering and idk why it dosent work for can-touch

Oh maybe cuz i wrote it after dropper:makejoints amma test someth

I know i mean they even not works

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)

This MAY Help

Okay seems that was problem, but roblox still lags huge, when i buy it

I said already tho upgrade button works, buy button don’t

--Buy button script

script.Parent.Touched:Connect(function()
    local Factory = game.ServerStorage.Model:Clone()
    Factory.Parent = workspace
	Factory:MakeJoints()
    script.Parent:Destroy()
end)

Still lags, when i clone factory idk why

Refresh Your PC Reopen Studio Restart Your PC Open Taskbar And Kill Apps May Help Reduce lag

I already did that much times, i think problem in other

For Lag Issue I cant Help It It May Be to do With Some Of Your script But not from these 2