Sell scripts won't disable

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m making a Settings UI, and inside an ImageButton I made this LocalScript, that says that if the Text of the button is on “Disabled”, the player won’t be able to sell his muscles, until he doesn’t click the button again, to make it appear as “Enabled”,

  2. What is the issue? The issue is that I tried many ways to disable these scripts, and indeed when I go testing I see that if I use any functions that I got in my mind to disable or even DESTROY the scripts, they actually vanish, but the sell function still works.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Yes, couldn’t find anything related specifically to my issue.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

First script that goes inside the internal circle of the Sell area, which is the main part that if touched sells the player’s muscle:

local deb = false -- The sell has a debounce of 2 seconds since I'm implementing an autosell boost inside my game, which avoids the fact that the player has to move inside the area to sell his muscles.
local part = script.Parent 
part.Touched:Connect(function(Hit)
	local Humanoid = Hit.Parent:FindFirstChild("Humanoid")
	if Humanoid then
		local player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		if player then
			local leaderstats = player:FindFirstChild("leaderstats")
		local money = leaderstats.Coins
			local Muscles = leaderstats.Muscle
			if Muscles.Value >= 0 then 
				if deb == false then
					deb = true
				money.Value = money.Value + Muscles.Value 
					Muscles.Value = 0
					wait(2)
					deb = false
						end			
					end	

			end
		
		end
end)

Second script that goes inside the ImageButton

local circleFakeInner = game.Workspace.Sell.circleFakeInner
local sellTouch = circleFakeInner.Parent.sellTouch
script.Parent.MouseButton1Click:Connect(function()
	script.Parent.Parent.Parent.Parent.SoundGroup.Sound:Play()
	if script.Parent.TextLabel.Text == "Disabled" then
		circleFakeInner.Script.Disabled = true
		sellTouch.Script.Disabled = true
		script.Parent.Parent.Parent.warningsFrame.SellWarning.Visible = true
	elseif script.Parent.TextLabel.Text == "Enabled" then
		script.Parent.Parent.Parent.warningsFrame.SellWarning.Visible = false
		circleFakeInner.Script.Disabled = false
        sellTouch.Script.Disabled = false 	
	end
end)

When testing, the scripts are disabled, but just keep working. Can anybody tell me why? I have a feeling that this is a really stupid mistake, but I tried everything that I could have in my mind so far. (Note that no errors appear in the Output)

You can easily do this by storing your script in a variable, and disabling it through that variable.
local script = script
script.Disabled = true

Already tried that and It didn’t work, I resolved by disabling the CanTouch property of the circle part of the Sell area. Thank you for your help tho

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.