I want this client script to be more secure, so exploiters have a hard time messing with it.
I do not know how to do that besides using remotes and GUIDS.
Going here.
Code
--!strict
local ModuleQ = require(script.QuestionsAndAnswers)
local MainFrameQ = script.Parent.MainFrameQuestions
local function _init()
local Success,Ret = pcall(function()
for _,tbl in next,ModuleQ do
local new = MainFrameQ.MainClip.Template
if not MainFrameQ.MainClip:FindFirstChild(tbl[1]) then
local a = new:Clone()
a.Title.Text = tbl[1]
a.Answer.Text = tbl[2]
a.Name = tbl[1]
a.Parent = MainFrameQ.MainClip
a.Visible = true
end
end
local search = MainFrameQ.Search
search.FocusLost:Connect(function(enterPressed)
local text = search.Text
if text ~= '' and text ~= nil then
if enterPressed then
local foundMatch = false
for _, tbl in next, ModuleQ do
if string.find(text:lower(), tbl[3]:lower(), 1) then
local matchedFrame = MainFrameQ.MainClip:FindFirstChild(tbl[1])
if matchedFrame then
for _, child in next, MainFrameQ.MainClip:GetChildren() do
if child:IsA('Frame') and child.Name:lower() ~= 'template' then
child.Visible = false
end
end
matchedFrame.Visible = true
foundMatch = true
end
break
end
end
if not foundMatch then
for _, child in next, MainFrameQ.MainClip:GetChildren() do
if child:IsA('Frame') and child.Name:lower() ~= 'template' then
child.Visible = true
end
end
end
end
end
if text == '' then
for _, child in next, MainFrameQ.MainClip:GetChildren() do
if child:IsA('Frame') and child.Name:lower() ~= 'template' then
child.Visible = true
end
end
end
end)
local Lib = game.ReplicatedStorage.Shared.UI.Library
local GB = require(Lib.GenButton)
GB.new(
script.Parent.ToggleUi
)
GB.new(
script.Parent.ToggleQuestions
)
script.Parent.ToggleQuestions.Activated:Connect(function()
if not game.SoundService:FindFirstChild(`Clicked`) then
local new = game.ReplicatedStorage.Sounds.ClickSound:Clone()
new.Parent = game.SoundService
new:Play()
new.Ended:Connect(function()
task.spawn(function()
new:Destroy()
end)
end)
end
local att = script.Parent.ToggleQuestions:GetAttribute('Override')
if att then
MainFrameQ.Visible = not MainFrameQ.Visible
end
end)
script.Parent.ToggleUi.Activated:Connect(function()
if not game.SoundService:FindFirstChild(`Clicked`) then
local new = game.ReplicatedStorage.Sounds.ClickSound:Clone()
new.Parent = game.SoundService
new:Play()
new.Ended:Connect(function()
task.spawn(function()
new:Destroy()
end)
end)
end
for _,frame in next,script.Parent:GetChildren() do
if frame:IsA('Frame') then
frame.Visible = false
end
if frame:IsA('TextButton') or frame:IsA('ImageButton') then
if frame.Name:lower() ~= 'toggleui' then
local att = frame:GetAttribute('Override')
if att then
att = not att
end
frame.Visible = not frame.Visible
end
end
end
end)
end)
local httpmodule = require(game.ReplicatedStorage.Utility.httpText)
httpmodule(
'Bold',
script.Parent.ToggleQuestions,
script.Parent.ToggleQuestions.RichText
)
httpmodule(
'Bold',
script.Parent.ToggleUi,
script.Parent.ToggleUi.RichText
)
httpmodule(
'Underline',
script.Parent.ToggleUi,
script.Parent.ToggleUi.RichText
)
httpmodule(
'Underline',
script.Parent.ToggleQuestions,
script.Parent.ToggleQuestions.RichText
)
return Success,Ret
end
local Success,Return = _init()
if Success then
warn('_init successfully ran and loaded all HUD elements | ',script:GetFullName())
else
error(tostring(Return) or Return,5)
end