Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How Do I Make myself visible to 1 player only?

Ok, I want to make myself visible to 1 player. Basically I use a script to choose a player randomly, then that player is the only one who can see me. Everyone else cannot.

Script I have so far:

local LocalPlayer = game. Players.LocalPlayer

local players = game.Players:GetChildren()

local  RandomPlayer = players [math.random(1, #players)]

repeat wait() RandomPlayer = players [math.random(1, #players)] until RandomPlayer ~=  LocalPlayer


2 answers

You can put a LocalScript inside the players and use a RemoteEvent, use a tuple argument meaning the player:

Script

local LocalPlayer = game. Players.LocalPlayer
	 
	local players = game.Players:GetChildren()
	 
	local  RandomPlayer = players [math.random(1, #players)]
	 
	repeat wait() RandomPlayer = players [math.random(1, #players)] until RandomPlayer ~=  LocalPlayer

(LOCATION OF THE REMOVEEVENT):FireAllClients(RandomPlayer.Name)

LocalScript (inside the player)

(LOCATION OF THE REMOVEEVENT).OnServerEvent:Connect(function(player)
	if player == script.Parent.Name then

		--code here

	end
end)

I cannot help you that much here because I wrote this without checking if it works, if you have any other question ask me :).

I Havent Tested It (Bc i made this in class) Make Regular Script And Put This In ServerScriptService

local Players = game.Players.LocalPlayer



local YourPlayerUser = game.Players.LocalPlayer
local YourCharacter = game.Workspace:WaitForChild(YourPlayerUser.Name)

local Parts = YourCharacter:GetChildren()

for i, v in pairs(Players) do
	local Player = Players:FindFirstChild('Put The Player UserHere')
		if Player then
			Parts.Transparency = 0
		else
			Parts.Transparency = 1
		end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.