Hello, I am making a building / placement system that includes electronics of all kinds, and now I started work on an elevator which you can input the values of how far in the x,y,z you want it to go using textboxes.
However a textbox requires a script on the client for it to work, and there is no possible way to get its text without using remote events (from my knowledge), and I am really having trouble figuring out how I can do this.
Here is the main server script module, whenever the GotInput:FireServer() fires, it fires to every single elevator that exists in the game and I only want it to send to the elevator that has the matching textbox input thing.
function Electronics.MultiFloorElevator(Elevator,LogisticPorts)
local GotInput = ReplicatedStorage.RemoteEvents.GotInput -- this event will detect when an input box gets, well, an input
task.wait(0.5)
GotInput:FireAllClients(Elevator)
GotInput.OnServerEvent:Connect(function(plr,XYZ_Input,matchingPort)
local x,y,z = table.unpack(XYZ_Input)
print(x,y,z,matchingPort)
end)
end
Here is my client script, I need to somehow send the data from GotInput:FireServer() to the specific model that it has been inputted into.
GotInput.OnClientEvent:Connect(function(Model)
if Model.Name == 'MultiFloorElevator' then
-- messy chunk of code, ignore, irrelevant, only takes up space, checks for textboxes
for _,inputBox : TextBox in pairs(Model:GetDescendants()) do
if inputBox:IsA('TextBox') then
inputBox.FocusLost:Connect(function(enterPressed)
local text = inputBox.Text
text:gsub(" ", "")
local x, y, z = table.unpack(string.split(text, ","))
local matchingPort = Model:FindFirstChild('LogisticPort' .. string.gsub(inputBox.Name, "%D", ""))
-- if value is nil or player didn't input, then just set to 0
if enterPressed then
GotInput:FireServer({x or 0, y or 0, z or 0},matchingPort)
end
end)
end
end
end
end)
Its probably not relevant but here is how the elevator looks like
The player inputs stuff into the Move by: boxes, and I need to send that data to the appropriate script for this