Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How Do I Make myself visible to 1 player only?

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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 :).

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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

Answer this question