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

How to make a GUI Button make a Disabled Local Script From StarterCharacterScript = True?

Hello, Im trying to make a GUI Button that make a Disabled Local Script turn to Enabled. But my scripting sucks. Nothing i made didn't work. Please help me. Im thankful to you.

local TextButton = script.Parent.Parent.Parent
LocalScript = script.Parent.Parent.LocalScript

function onClick()
	if LocalScript.Disabled == false then
		LocalScript.Disabled = true
	elseif LocalScript.Disabled == true then
		LocalScript.Disabled = false
	end
end

Button.MouseButton1Click:connect(onClick)

2 comments

0

you have to make a script first and then paste it in and select it and click the lua changer thing and the community will help you fix it until it works.

0

I see. Thanks

1 answer

✓ Accepted answer

Local Script (this change would be on the Client only)

local player = game.Players.LocalPlayer
repeat wait() until player.Character ~= nil and workspace:FindFirstChild(player.Name) ~= nil
local TextButton = script.Parent.Parent.Parent
LocalScript = player.Character.LocalScript

TextButton.Activated:Connect(function(onClick)
	if LocalScript.Disabled == false then
		LocalScript.Disabled = true
	elseif LocalScript.Disabled == true then
		LocalScript.Disabled = false
	end
end)

ISSUES

A. Make sure that your variables are correctly named in your script (you defined TextButton, but used "Button" to connect the function)

B. Use Activated rather than MouseButton1Click since Activated works for all devices, not just computers

C. The LocalScript from StarterPlayerScripts will be parented under the player's Character, so that's the definition to index

D. Player Characters load before they are placed into the workspace, so you have to wait for it to be in the workspace before it is used in the script

E. Make sure that the TextButton is under the StarterGui in some way, unless you are directly parenting it to the PlayerGui via a Script.

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