Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Cannot grab text from text box?

Asked by
Jxyzxrr 13
5 years ago

local remote = game.ReplicatedStorage.Remotes.execute

remote.OnServerEvent:connect(function()

loadstring(game.StarterGui.ScreenGui.Frame.require.Text)

end)

I have made an execute gui for serverside modules/basic scripts. When I try it, there is no output.

Yes, I made a script inside the button to fire the remote when clicked. That part is fine, it doesn't execute anything though.

And I did see something. When you go to the properties of the TextBox, and then type text in the box in-game, it doesn't show in properties.

0
what r u trying to do with this? Gameplayer365247v2 1055 — 5y

2 answers

Log in to vote
0
Answered by
Kymaraaa 116
5 years ago
Edited 5 years ago

You're first problem is that you're trying to access the Players textbox from the server by accessing the StarterGui.

The StarterGui is the place where you put your GUI which will get cloned into the players PlayerGui when they spawn. Another problem is that you cannot access the contents of the PlayerGui from the server.

What you'll want to do is pass the Text from the client, to the server via arguments in your Remote Event.

-- On both the Client and Server
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("Remotes"):WaitForChild("execute")

-- Client
local TextBox = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("ScreenGui"):WaitForChild("Frame"):WaitForChild("require")
RemoteEvent:FireServer(TextBox.Text)

-- Server
RemoteEvent.OnServerEvent:Connect(function(Player, Text)
    loadstring(Text)
end)
0
"you cannot directly access the Players Gui from the server" You're partially wrong. The server can access the PlayerGui and drop clones in it, it just can't access what it put in there. DeceptiveCaster 3761 — 5y
0
That's what I meant, I'll edit the post to be more specif. Kymaraaa 116 — 5y
0
RobloxWhizYT you can technically do it through remote events if you find the playergui of the player who fired. xForVowels 6 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

I'd recommend a remote event to do this for you, you should try something like:

--first make a remote
yourremote.OnServerEvent:connect(function(LocalPlayer)
if LocalPlayer.UserId == 'your user id here' then
    loadstring(tostring(LocalPlayer.PlayerGui.your textbox path.Text))
else
    LocalPlayer:Kick()
end

Exploiters won't be able to backdoor and it serves the same function as what you are trying to do. PS: You could have also just used F9 server console.

Answer this question