How can i make a setting that disables sell in my simulator game? i have tried making a few scripts they end up not working this is one of the scripts i have tried:
script.Parent.MouseButton1Click:Connect(function() if game.Workspace.SellingPart.Sell.Disabled == true then game.Workspace.SellingPart.Sell.Disabled = false game.Workspace.SellingPart.Sound.Disabled = false else game.Workspace.SellingPart.Sell.Disabled = true game.Workspace.SellingPart.Sound.Disabled = true end end)
so yea if you can help me then thanks.
This is a very common mistake, as known as a misconception of switching lights on and off, by making that detects if it's true, on the light. What are you currently is doing is passing two statements, when the Sell is disabled, it goes to the if statement of detecting if the Sell is disabled, and then switch it true. If your default setting had Selling Disabled true, then it pass through the if that sets the Disabled false and passed through another statement and set it true.
Anyways, you can use if-else with this.
script.Parent.MouseButton1Click:Connect(function() if game.Workspace.SellingPart.Sell.Disabled == true then game.Workspace.SellingPart.Sell.Disabled = false game.Workspace.SellingPart.Sound.Disabled = false else game.Workspace.SellingPart.Sell.Disabled = true game.Workspace.SellingPart.Sound.Disabled = true end end)
If this doesn't work, make it as a LocalScript and insert this instead:
wait() script.Parent.MouseButton1Click:Connect(function() if game.Workspace.SellingPart.Sell.Disabled == true then game.Workspace.SellingPart.Sell.Disabled = false game.Workspace.SellingPart.Sound.Disabled = false else game.Workspace.SellingPart.Sell.Disabled = true game.Workspace.SellingPart.Sound.Disabled = true end end)
DONT PUT THE SCRIPT/ LOCALSCRIPT IN WORKSPACE OR SERVERSCRIPTSERVICE, PUT IT INSIDE THE TEXTBUTTON.