Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
Bertox 159
6 years ago
Edited 6 years ago

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)
0
not working andtheres no error Lolamtic 63 — 6y
0
dude with no script.Disabeld or Disabled = true Lolamtic 63 — 6y
0
oh forgot to remove lol Bertox 159 — 6y
0
Is it working? Bertox 159 — 6y
View all comments (3 more)
0
edit the anwer and remove thte script.Disabled part remove line 13-14 and 7-8 Lolamtic 63 — 6y
0
can you rate my answer please :3 Bertox 159 — 6y
0
Thx u did your job ;D ;) Lolamtic 63 — 6y
Ad

Answer this question