What do you want to achieve? Keep it simple and clear!
Hello, I am not a very good scripter but I made a Code Checker script that checks if the code is correct and I made a cancel button in a function to exit the gui.
What is the issue? Include screenshots / videos if possible!
So the problem is when I press cancel and Input a number into the textbox then press enter it doesn’t print or show an error in the output.
How do I make my Code Checker better? And how do I only allow players to Input only numbers and also how can I limit the number? Example they can only enter 6 Numbers not more than that.
local Code_Input = script.Parent:WaitForChild("TextBox")
local Selective_Text = script.Parent:WaitForChild("Selective_Text")
local CanType = false
local Code = {
"22567"
}
local function Check_Code()
if Code_Input.Text ~= Code then
print("Player has input a wrong code!")
Selective_Text.TextColor3 = Color3.fromRGB(244, 0, 0)
Selective_Text.TextTransparency = 0
Selective_Text.Text = "You have entered an incorrect code!"
end
end
script.Parent.Enter.MouseButton1Click:Connect(function()
Check_Code()
print("hey")
end)
local function Cancel()
Code_Input.Text = ""
if script.Parent.Parent.Frame.Visible == true then
script.Parent.Parent.Frame.Visible = false
end
end
script.Parent.Cancel.MouseButton1Click:Connect(Cancel)
I would be really appreciated if someone could help me out!
As I can tell, it seems like you’re doing the checks on the client side - which is not the best to do.
Instead, you should invoke a remote function to the server,[provide the input text as an argument], and on the server do the checks. [You can use return to return data, and with that, you could display ‘error’, ‘success’ depending on the result of the returning.
There are many tutorials on youtube and probably on the forum aswell on how to make a safe ‘twitter code’ system.
Still, if the code is important and relevant [and necessary], you should communicate between the client and the server, otherwise, exploiters could easily change that local script [even delete it], and sneak in.
Remote Functions. Remote functions are basically like remote events, accept they allow you to return data. For this, instead of FireServer() and OnServerEvent use InvokeServer() and OnServerInvoke.