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

How to merge 2 localScripts to one localscript?(MOUSEBUTTON1GUI)?

LocalScript

script.Parent.MouseButton1Click:connect(function()
local startergui = game:GetService("StarterGui")
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
script.Parent.LocalScript2.Disabled = false
script.Disabled = true
end)

LocalScript2

script.Parent.MouseButton1Click:connect(function()
local startergui = game:GetService("StarterGui")
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
script.Parent.LocalScript.Disabled = false
script.Disabled = true
end)

How to make those 2 Chat disabler / enabler functions into one Script!?!

1 answer

✓ Accepted answer

Use variables and if function

local on = false
script.Parent.MouseButton1Click:connect(function()
	if on == true then --checks if on is set to true
		on = false --setting on to false
		local startergui = game:GetService("StarterGui")
		startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, false)
	elseif on == false then --checks if on is set to false
		on = true --setting on to true
		local startergui = game:GetService("StarterGui")
		startergui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, true)
end
end)

7 comments

0

not working andtheres no error

0

dude with no script.Disabeld or Disabled = true

0

oh forgot to remove lol

0

Is it working?

0

edit the anwer and remove thte script.Disabled part remove line 13-14 and 7-8

0

can you rate my answer please :3

0

Thx u did your job ;D ;)

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