Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can i make a setting that disables sell in my simulator game?

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.

1 answer

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)

#NOTE:

DONT PUT THE SCRIPT/ LOCALSCRIPT IN WORKSPACE OR SERVERSCRIPTSERVICE, PUT IT INSIDE THE TEXTBUTTON.

This discussion is preserved as it was. New answers, comments, and votes are closed.