Hi i’m making this post because I made a script that, when someone types a secret code, it prints either CORRECT or INCORRECT. But since i’m a beginner, it wasn’t working for some reason and there’s notihng on the output page
Scripts:
local CodeValue = script.Parent.Parent.Parent.Parent.Parent.PC.Screen.Code
script.Parent.Prompt.Triggered:Connect(function(player)
game.ReplicatedStorage.EnableKGUI:FireClient(player)
local GUI = player.PlayerGui.KeycodeGUI
if GUI.Done.Value == true then
print("User has given a code")
if GUI.Frame.Frame.CodeSee.Text == CodeValue.Value then
print("CORRECT")
else
print("INCORRECT")
end
end
end)
script path
local KGUI = game.Players.LocalPlayer.PlayerGui.KeycodeGUI
local Chiffre = KGUI.Frame.Frame.CodeSee
local frame = script.Parent.Frame.Frame.Frame
game.ReplicatedStorage.EnableKGUI.OnClientEvent:Connect(function()
KGUI.Enabled = true
KGUI.Frame:TweenPosition(UDim2.new(0,0,0,0),"Out","Back",1,false)
end)
KGUI.Frame.X.MouseButton1Click:Connect(function()
KGUI.Enabled = false
end)
for i ,key in pairs(frame:GetChildren()) do
if string.find(key.Name, "Key") then
key.MouseButton1Click:Connect(function()
Chiffre.Text ..= string.match(key.Name, "%d")
end)
elseif key.Name == "Back" then
key.MouseButton1Click:Connect(function()
Chiffre.Text = string.sub(Chiffre.Text,1,0)
end)
elseif key.Name == "Enter" then
key.MouseButton1Click:Connect(function()
script.Parent.Done.Value = true
end)
end
end
localscript path
Note: Everything works except when the server tries to know if the value is true
I’m thinking maybe one of the 2 scripts can’t access the value but then it would probably error though …
remote event path :
i’m going to sleep sorry i’ll check on this post tomorrow
--script
local CodeValue = script.Parent.Parent.Parent.Parent.Parent.PC.Screen.Code
game.ReplicatedStorage.EnableKGUI.OnServerEvent:Connect(function(player)
local GUI = player.PlayerGui.KeycodeGUI
if GUI.Done.Value == true then
print("User has given a code")
if GUI.Frame.Frame.CodeSee.Text == CodeValue.Value then
print("CORRECT")
else
print("INCORRECT")
end
end
end)
script.Parent.Prompt.Triggered:Connect(function(player)
game.ReplicatedStorage.EnableKGUI:FireClient(player)
end)
--local
local KGUI = game.Players.LocalPlayer.PlayerGui.KeycodeGUI
local Chiffre = KGUI.Frame.Frame.CodeSee
local frame = script.Parent.Frame.Frame.Frame
game.ReplicatedStorage.EnableKGUI.OnClientEvent:Connect(function()
KGUI.Enabled = true
KGUI.Frame:TweenPosition(UDim2.new(0,0,0,0),"Out","Back",1,false)
end)
KGUI.Frame.X.MouseButton1Click:Connect(function()
KGUI.Enabled = false
end)
for i ,key in pairs(frame:GetChildren()) do
if string.find(key.Name, "Key") then
key.MouseButton1Click:Connect(function()
Chiffre.Text ..= string.match(key.Name, "%d")
game.ReplicatedStorage.EnableKGUI:FireServer()
end)
elseif key.Name == "Back" then
key.MouseButton1Click:Connect(function()
Chiffre.Text = string.sub(Chiffre.Text,1,0)
game.ReplicatedStorage.EnableKGUI:FireServer()
end)
elseif key.Name == "Enter" then
key.MouseButton1Click:Connect(function()
script.Parent.Done.Value = true
game.ReplicatedStorage.EnableKGUI:FireServer()
end)
end
end
Instead of using a remoteevent and setting a bool val to true use a RemoteFunction as it returns info that is returned when calling the :InvokeServer or :InvokeClient!
--script
local CodeValue = script.Parent.Parent.Parent.Parent.Parent.PC.Screen.Code
game.ReplicatedStorage.EnableKGUI.OnServerEvent:Connect(function(player)
local GUI = player.PlayerGui.KeycodeGUI
if GUI.Done.Value == true then
print("User has given a code")
if GUI.Frame.Frame.CodeSee.Text == CodeValue.Value then
print("CORRECT")
else
print("INCORRECT")
end
end
end)
script.Parent.Prompt.Triggered:Connect(function(player)
game.ReplicatedStorage.EnableKGUI:FireClient(player)
end)
--local
local KGUI = game.Players.LocalPlayer.PlayerGui.KeycodeGUI
local Chiffre = KGUI.Frame.Frame.CodeSee
local frame = script.Parent.Frame.Frame.Frame
game.ReplicatedStorage.EnableKGUI.OnClientEvent:Connect(function()
KGUI.Enabled = true
KGUI.Frame:TweenPosition(UDim2.new(0,0,0,0),"Out","Back",1,false)
end)
KGUI.Frame.X.MouseButton1Click:Connect(function()
KGUI.Enabled = false
end)
local function pressedButton(x)
local s= string.sub(x,4,4)
if Chiffre.Text~=""then
Chiffre.Text=Chiffre.Text..s
else
Chiffre.Text=s
end
end
for i,v in pairs(frame:GetChildren()) do
v.MouseButton1Click:Connect(function()
local len=#Chiffre.Text
if v.Name=="Enter"then
script.Parent.Done.Value = true
game.ReplicatedStorage.EnableKGUI:FireServer()
elseif v.Name=="Back"then
if len>1 then
local s=string.sub(Chiffre.Text,1,#Chiffre.Text-1)
Chiffre.Text=s
elseif len==1 then
Chiffre.Text=""
else
Chiffre.Text=""
end
else
v.MouseButton1Click:Connect(pressedButton(v.Name))
end
end)
end
--script
local CodeValue =script.Parent.Parent.Parent.Parent.Parent.PC.Screen.ChildRemoved
game.ReplicatedStorage.EnableKGUI.OnServerEvent:Connect(function(player,complete,text)
local GUI = player.PlayerGui.KeycodeGUI
GUI.Done.Value=complete
if GUI.Done.Value == true then
print("User has given a code")
if text == CodeValue.Value then
print("CORRECT")
else
print("INCORRECT")
end
end
end)
script.Parent.Prompt.Triggered:Connect(function(player)
game.ReplicatedStorage.EnableKGUI:FireClient(player)
end)
--local
local KGUI = game.Players.LocalPlayer.PlayerGui.KeycodeGUI
local Chiffre = KGUI.Frame.Frame.CodeSee
local frame = script.Parent.Frame.Frame.Frame
game.ReplicatedStorage.EnableKGUI.OnClientEvent:Connect(function()
KGUI.Enabled = true
KGUI.Frame:TweenPosition(UDim2.new(0,0,0,0),"Out","Back",1,false)
end)
KGUI.Frame.X.MouseButton1Click:Connect(function()
KGUI.Enabled = false
end)
local function pressedButton(x)
local s= string.sub(x,4,4)
if Chiffre.Text~=""then
Chiffre.Text=Chiffre.Text..s
else
Chiffre.Text=s
end
end
for i,v in pairs(frame:GetChildren()) do
v.MouseButton1Click:Connect(function()
local len=#Chiffre.Text
local done=script.Parent.Done
if v.Name=="Enter"then
done.Value = true
game.ReplicatedStorage.EnableKGUI:FireServer(done.Value,Chiffre.Text)
elseif v.Name=="Back"then
if len>1 then
local s=string.sub(Chiffre.Text,1,#Chiffre.Text-1)
Chiffre.Text=s
elseif len==1 then
Chiffre.Text=""
else
Chiffre.Text=""
end
else
v.MouseButton1Click:Connect(pressedButton(v.Name))
end
end)
end
seems you have some trouble since i modified the code:
--script
local CodeValue = script.Parent.Parent.Parent.Parent.Parent.PC.Screen.Code
game.ReplicatedStorage.EnableKGUI.OnServerEvent:Connect(function(player,complete,text)
local GUI = player.PlayerGui.KeycodeGUI
GUI.Done.Value=complete
if GUI.Done.Value == true then
print("User has given a code")
if text == CodeValue.Value then
print("CORRECT")
else
print("INCORRECT")
end
end
end)
script.Parent.Prompt.Triggered:Connect(function(player)
game.ReplicatedStorage.EnableKGUI:FireClient(player)
end)
--local
local KGUI = game.Players.LocalPlayer.PlayerGui.KeycodeGUI
local Chiffre = KGUI.Frame.Frame.CodeSee
local frame = script.Parent.Frame.Frame.Frame
game.ReplicatedStorage.EnableKGUI.OnClientEvent:Connect(function()
KGUI.Enabled = true
KGUI.Frame:TweenPosition(UDim2.new(0,0,0,0),"Out","Back",1,false)
end)
KGUI.Frame.X.MouseButton1Click:Connect(function()
KGUI.Enabled = false
end)
for i ,key in pairs(frame:GetChildren()) do
if string.find(key.Name, "Key") then
key.MouseButton1Click:Connect(function()
Chiffre.Text ..= string.match(key.Name, "%d")
end)
elseif key.Name == "Back" then
key.MouseButton1Click:Connect(function()
Chiffre.Text = string.sub(Chiffre.Text,1,0)
end)
elseif key.Name == "Enter" then
key.MouseButton1Click:Connect(function()
script.Parent.Done.Value = true
game.ReplicatedStorage.EnableKGUI:FireServer(script.Parent.Done.Value,Chiffre.Text)
end)
end
end
this version i just added the server event and passed arguments into the fire server everything else untouched