i got a machine that asks for you to input a code into a TextBox. when you type into the textbox as a player, the text will be there on the client side, and not the server side. that is why i have cooked up a series of scripts, remote events, and a single string value object for this single darn passcode machine.
there is a button to confirm your code, and a screen display.
this first script is stored all in the button. it is the main script.
local me = script.Parent
local cd = me.ClickDetector
local sound = me["Switches Clicks Buttons Various Versions 7 (SFX)"]
local screen = me.Parent.screen
local debounce = false
local event = game.ReplicatedStorage["code machine"]
local serve = game.ReplicatedStorage["code mach server"]
local val = me.Value
cd.MouseClick:Connect(function(plr)
if debounce == false then
debounce = true
sound:Play()
event:FireAllClients()
task.wait()
if val.Value == "4" then
cd:Destroy()
screen.SurfaceGui.TextLabel.Text = "Correct. Here is your key, Xorx."
me["Synth Sparkle Tone High Pitch Bell Tone Burs (SFX)"]:Play()
else
screen.SurfaceGui.TextLabel.Text = "Count again."
end
task.wait(2)
screen.SurfaceGui.TextLabel.Text = "How many shelves are there in helf Life?"`
debounce = false
end
end)
this next script is the localscript that gets the value of the textbox on the client side:
local me = script.Parent
local event = game.ReplicatedStorage["code machine"]
local serve = game.ReplicatedStorage["code mach server"]
local box = me.Parent.screen.SurfaceGui.TextBox
local val = me.Value
print("the localscript exists")
event.OnClientEvent:Connect(function()
serve:FireServer(box.Text)
print(box.Text)
end)
the next script is another server script that recieves the value sent back by the localscript, and finally sets a string value’s value to the code typed out by the player:
local me = script.Parent
local event = game.ReplicatedStorage["code mach server"]
local val = me.Value
event.OnServerEvent:Connect(function(plr, code)
val.Value = code
print(code)
print(val.Value)
end)
after all of that, the main server script uses the stringvalue’s value and checks if it matches the correct answer. however, it doesn’t do any of that at all. when i check the console, completely nothing is printed by the scripts, probably saying that the events have not been fired at all. or maybe it’s smth else.
also, i decided to print smth right as the localscript starts running, and the print doesn’t print at all, also probably saying that the localscript does not exist.