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!!!
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:
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | local Code = script.Parent.Parent.TextBox.Text |
3 | game.ReplicatedStorage.Respawn:FireServer(Code) |
4 | end ) |
Now in the script inside of ServerScriptService type this:
1 | game:GetService( "ReplicatedStorage" ):WaitForChild( "Respawn" ).OnServerEvent:Connect( function (Player, Code) |
2 | if Code = = "CODE HERE" then |
3 | -- Code here on how to respawn, etc |
4 | end |
5 | end ) |
If this helped please help me out by accepting the answer. And good luck on your game!