You can write your topic however you want, but you need to answer these questions:
-
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”, -
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.
-
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)