Recently, I have been working quite a bit on a little system of mine, but I have run into some issues. Despite the fact that the scripts work fine, and the event I will present fires, I cannot seem to send the variable from the LocalScript to the ServerScript. The function/event works, but the variable simply does not go through along with it.
Typically, I spend about an hour looking through the DevForum and the official development webpage, and then another applying what I have learned. This time, however, none of that worked, and I am forced to either take even more time trying to understand the problem, or make a post. I have chosen the latter option.
The LocalScript, which works just fine and fires the event as I need it to:
local function OnClicked()
local cname = script.Parent.Parent.Parent.computer.Value
local console = script.Parent.Parent.console
local ctext = console.Text -- Value taken from a TextBox
local comps = game.Workspace:GetChildren()
for i, v in pairs(comps) do
if v.Name == "PC" then
if v.pcname.Value == cname then
v.readconsole:FireServer(ctext) -- Fires the event.
end
end
end
end
script.Parent.MouseButton1Down:Connect(OnClicked)
And the server script, which is activated when the event is fired, but fails to actually use the variable, or receive it:
local plr = script.Parent.tempdata.plrname
local pname = plr.Value
local player = game.Players[pname]
local SSSMonitor = player.PlayerGui:FindFirstChild("SSSMonitor")
local running = SSSMonitor.running
local console = running.console
local enter = running.enter
local txt
script.Parent.readconsole.OnServerEvent:Connect(function(txt) -- Event is fired.
print("works") -- This works just fine...
print(txt) -- ... but this does not.
end)
Of course, I am only posting these here without all of the scripts, as the full system of scripts and objects is not only too large to stick in a post about something as small as this, but it is also unrelated to the problem, as the scripts function, but the variables do not.
Essentially, the “ctext” and “txt” variables fail to match up.
So far, I have used print()
to debug my scripts. There are no errors. In addition, I have swapped the variable around with normal strings: still no results.
I am on my last five braincells. Other events work just fine from documents on the internet. This does not.