Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to make a text box that fires a remote thats name is the text box's text?

So i have been working on a game for awhile that is sorta like ZORK, that old text based game. The game is GUI / model based with no direct input, just typed commands.

Here are some photos of my code as well as the error i'm having

https://imgur.com/a/QZyo7no

as you can see back exists in the ReplicatedStorage as well as the path of the text box = back.

However for some reason the script errors saying back doesn't exist in ReplicatedStorage?

Can someone help me please?

Thank you.

1 comment

0

weird.. try iterating ReplicatedStorage's children and print their names to check if "back" actually exists.

1 answer

Possible solutions:

  1. Make sure "back" Event is created by a server script, or create it manually in studio. If it is created by a localScript, it will not replicate.
  2. To make sure the event has loaded, use:
local backEvent = game.ReplicatedStorage:WaitForChild(pathname.Text)
backEvent:FireServer()

p.s. For GUI buttons it is easier to make seperate local scripts parented to the button itself. Then instead of

local button = game.LocalPlayers.LocalPlayer.PlayerGui.s.f.b

you'll have

local button = script.Parent
local pathname = script.Parent.Text --assuming you will copy the path text to the button as well

p.s.2 Instead of having separate events, which could get unmanageable once your game grows in size, you could simply pass name through the event

local buttonPressedEvent = game.ReplicatedStorage:WaitForChild("ButtonPressedEvent")
buttonPressedEvent:FireServer(pathname.Text)

Edit: stupid mistake

This discussion is preserved as it was. New answers, comments, and votes are closed.