How can I force player to not spawn when joining the game and after dying and only spawn in when clicking on a gui or something?
All this can only be used in a server script. In case you have a button, you’ll either have to use a server script, or a local script and communicate with a server via a remote event.
local Players = game:GetService("Players")
Players.CharacterAutoLoads = false
-- on request
player:LoadCharacter()
To add to this, basically, after disabling character auto loads only the server will be able to load the player character/spawn them, manually through code. So you can have a UI on the client that fires a remote event to the server requesting to respawn, the server checks if that specific player can respawn according to the in-game rules(the reason the server checks instead of the client is so it’s not bypassable through exploits) and if the server concludes the player can respawn, runs player:LoadCharacter()
on the server to respawn them(the player who fired the remote is passed to the server as the first argument, so it’s also not bypassable by exploits).