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

local Instance, and CurrentCamera help?

Asked by 9 years ago

I need to make a script that makes a SelectionBox invisible to a specific player, and visible to all the other players. I'm assuming I have to place the selection box in all of the player's cameras. Though I'm not exactly sure on how to go about this.

Here's what I'm using now, when a player enter's it creates a selectionbox places it in the Player's CurrentCamera, and set's the Adornee to The Player's torso. This makes it visible to the local player, and invisible to everyone else. Basically I need to do the opposite. Though I'm having trouble figuring that out.

This is a Local script in the StarterGui

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character

wait()
local box = Instance.new("SelectionBox", game.Workspace.CurrentCamera)
box.Color = Player.TeamColor
box.Adornee = Player.Character:WaitForChild("Torso")

Player.Character.Humanoid.Died:connect(function(Death)
game.Workspace.CurrentCamera:FindFirstChild("SelectionBox"):Destroy()
end)
0
Put the SelectionBox in the player's PlayerGui, not their Camera. A SelectionBox is just a GuiObject. Tkdriverx 514 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

Use a Server-Side Script to do this.

for _,Plyr in pairs(game.Players:GetPlayers()) do
    if Plyr ~= IGNORED_PLAYER then --Replace IGNORED_PLAYER with the Player that will not see the selection boxes
        for _,v in pairs(game.Players:GetPlayers()) do
            if v ~= Plyr then --This prevents Plyr from having a selectionbox
                local Box = Instance.new("SelectionBox",Plyr.PlayerGui)
                Box.Color = v.TeamColor --Makes the selectionbox color the same as the teamcolor of the player that the selectionbox is attached to
                Box.Adornee = v.Character:WaitForChild("Torso")
                v.Character:WaitForChild("Humanoid").Died:connect(function()
                    Box:Destroy() --Removes the Box if the player that has the selectionbox dies
                end)
            end
        end
    end
end

Hope this helped!

0
Doesn't seem to be working Turbo. QuillStrike 60 — 9y
0
What's the problem? TurboFusion 1821 — 9y
Ad

Answer this question