how do i make a gui that pop up when you try to leave the game it will let you confirm and if you confirm the game will close but if cancel it will stay in the game
I’m pretty sure detecting when a player is attempting to leave is not possible on Roblox, as this would cause a lot of abuse. I am aware that this has been done before, but I’m pretty sure this was against the TOS.
You can however detect when the player leaves with .onPlayerRemoving
Hope that helps.
ok thenks but how can i remove the 20 min afk thing that kick the player after 20 min
There have been many forum posts about disabling the 20-minute idle kick. The oldest post I could find relating to this is here.
Short answer, you can’t.
I wonder, does simulating a click essentially help prevent it?
Localscript in starterplayerscripts (I’m not testing it)
game.Players.LocalPlayer.Idled:Connect(function()
game:GetService("VirtualUser"):ClickButton1()
end)
People have tried this, and it didn’t work for them. I guess the actual Roblox core scripts that actually kick the player after 20 minutes look for real client input.
Interesting, then what about this (only works if your game doesn’t have any place teleports):
local script in starterplayerscripts
local player = game.Players.LocalPlayer
local position = game:GetService("TeleportService"):GetLocalPlayerTeleportData()
local character = player.Character or player.CharacterAdded:Wait()
character:PivotTo(position)
use this to teleport the player to its own server instance
function respawn(player)
game:GetService("TeleportService"):TeleportToPlaceInstance(game.PlaceId, game.JobId, player, player.Character.PrimaryPart:GetPivot()
end
game.Players.PlayerAdded:Connect(function(player)
player.Idled:Connect(function()
respawn(player)
end)
end)
People have been thinking about teleporting a player to a secondary game, with CharacterAutoLoad disabled, and having absolutely nothing in the game, except one script, which teleports them back to the primary game.
It works, and I think that’s the only option.
Kavra’s Kingdom, and I know this since I used to play it, uses a system that happens every few minutes which forces the player to rejoin.
It’s quite sad that it shut down.
It’s probably impossible since the player would be forced to leave anyway. Although, there already is a confirmation gui for leaving.
i want a confirm for that leave like if you try to leave it will give the gui and if press on a button it will leave