I'm making a Roblox Camping game, but the problem is I don't want my friends to have to ALWAYS pay robux to respawn. So I decided to make a secret code you may type to respawn. the problem is, I DON'T KNOW HOW!!!
✓ ANSWER ACCEPTED
How do I make a function on typed in a text box?
1 answer
✓ Accepted answer
Here is a way you can do it.
Make a RemoteEvent in ReplicatedStorage called "Respawn"
Make a TextBox in the Respawn gui
Make a TextButton in the Respawn gui too
Make a script inside of ServerScriptService
Make a script inside the TextButton
In the script inside of the TextButton inside of the Respawn gui put this into it:
script.Parent.MouseButton1Click:Connect(function()
local Code = script.Parent.Parent.TextBox.Text
game.ReplicatedStorage.Respawn:FireServer(Code)
end)
Now in the script inside of ServerScriptService type this:
game:GetService("ReplicatedStorage"):WaitForChild("Respawn").OnServerEvent:Connect(function(Player, Code)
if Code == "CODE HERE" then
-- Code here on how to respawn, etc
end
end)
If this helped please help me out by accepting the answer. And good luck on your game!
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thank you! Lemme check though. Is the text button the submit thing?