How do i make certain GUIs show for different custom characters?

Hi so I’m not a pro when it comes to scripting, I’m making a superhero type of game and each different superhero has different abilities’, the only way to use them is by clicking a GUI on screen but i dont know how to make it so different guis show for different custom characters, does anyone know how i can do this? thanks!

3 Likes

When a player joins a game, all the GUIs you make replicate to the player.

To make a GUI only show for a specific player, do
`game.Players:WaitForChild(tostring(player)).PlayerGuu

And then with this, you can now access the player’s gui. If you have a screen gui and a frame you want to show the player, you can then add on to my script that I showed you and do

.ScreenGui.Frame

This is pretty confusing at first, so tell me if you have anymore questions.

1 Like

yeah im confused in general about that

Let’s say your GUI that you want to show is a text label in a screen gui. If you want to show it to all players, do:

for _, player in pairs(game.Players:GetPlayers()) do Game.Players:WaitForChild(player).PlayerGui.ScreenGui.TextLabel.Visible = true end

If you only want to show a Gui to a specific player, then do

Game.Players:WaitForChild(player).PlayerGui.ScreenGui.TextLabel.Visible = true end

And replace player with the player you want the gui to show

3 Likes

would ‘player’ be the name of the custom characters?

Yes it is. You can replace “player” with the player you want the GUI to show.

thank you this helped a lot! :slight_smile:

The way I would do this is NOT a guaranteed or can be easily done a different way.

  1. I would create a StringValue and parent it to the player in a global script on join.
local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
    local Ability = Instance.new("StringValue")
    Ability.Name = "Ability"
    Ability.Parent = Player.Character

    -- Assign the StringValue's Value with the ability name.
end)
  1. Create a table pool for all the abilities in your game.
local Players = game:GetService("Players")

local AbilityPool = {
    "A", "B", "C"
}

Players.PlayerAdded:Connect(function(Player)
    local Ability = Instance.new("StringValue")
    Ability.Name = "Ability"
    Ability.Parent = Player.Character

    -- Assign the StringValue's Value with the ability name.
end)
  1. Create and place your ability guis’ in ReplicatedStorage and declare it in the script.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local AbilityPool = {
    "A", "B", "C"
}

Players.PlayerAdded:Connect(function(Player)
    local Ability = Instance.new("StringValue")
    Ability.Name = "Ability"
    Ability.Parent = Player.Character

    -- Assign the StringValue's Value with the ability name from datastore.
end)
  1. Create a for in pairs loop to find the Player’s ability.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local AbilityPool = {
    "A", "B", "C"
}

Players.PlayerAdded:Connect(function(Player)
    local Ability = Instance.new("StringValue")
    Ability.Name = "Ability"
    Ability.Parent = Player.Character

    -- Assign the StringValue's Value with the ability name from datastore.
    for i, v in pairs(AbilityPool) do
    end
end)
  1. Check the Player’s Ability and clone the GUI to their PlayerGui.
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local AbilityPool = {
    "A", "B", "C"
}

Players.PlayerAdded:Connect(function(Player)
    local Ability = Instance.new("StringValue")
    Ability.Name = "Ability"
    Ability.Parent = Player.Character

    -- Assign the StringValue's Value with the ability name from datastore.
    for i, v in pairs(AbilityPool) do
        if Player.Character:FindFirstChild("Ability") == v then
            local AbilityGui = ReplicatedStorage:FindFirstChild(v.."Gui") :Clone()
            AbilityGui.Parent = Player.PlayerGui
        end
    end
end)

I do not expect this to work nor should you expect it to work, however, you should take this as an example only.