I have player and if he leaving I want start a function something like
Players.PlayerRemoving:Connect(function()
end)
but with certain player
I have player and if he leaving I want start a function something like
Players.PlayerRemoving:Connect(function()
end)
but with certain player
If I'm understanding correctly, this might work
local plrs = game.Players:GetPlayers()
local plr = plrs[math.random(1, #plrs)]
game.Players.PlayerRemoving:Connect(function(player)
if player.Name == plr.Name then
end
end)
Sorry, don't work. It making bugs in my script.
Okay, let me see if I can modify my script so it works
If I'm understanding you correctly, then my edited code might work
I fixed it by bool "check" now it's not making bugs. Thanks you.
Just check for their username using an if statement.
local Players = game:GetService("Players")
Players.PlayerRemoving:Connect(function(player)
if player.Name == usernameWanted then
--Execute the following code
end
end)
Hope this helped!
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
is this certain player just someone on a specific team? or is it like an admin or something that should only work for him
You can thing it's randomly picked player by game.Players:GetPlayers [math.random(1, #game.Players:GetPlayers())