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

Why does the transparancy only work for a few seconds?

Asked by 4 years ago
game.StarterGui.health.white.BackgroundTransparency = 1
game.StarterGui.health.white.red.BackgroundTransparency = 1
game.StarterGui.health.white.red.green.BackgroundTransparency = 1

I'm trying to experiment with a health bar that I make so it's not appear when I'm in the neutral team which is for main menu. But I want to try to make it transparent at all team for now. I click run not play and it works. But when I click play it appears. Is there anything wrong with it?

1 answer

Log in to vote
0
Answered by
DesertusX 435 Moderation Voter
4 years ago
Edited 4 years ago

The reason it only works on "run" is because the StarterGuis were not replicated into the player because there aren't any. To fix this, use PlayerGui which is inside the player.

local players = game.Players:GetPlayers() --Setting out a table of the players.

for _,player in pairs(players) do --Looping through each player in the game

    local playerGui = player:WaitForChild("PlayerGui") --Defining a variable for the PlayerGui

        playerGui.health.white.BackgroundTransparency = 1
        playerGui.health.white.red.BackgroundTransparency = 1
        playerGui.health.white.red.green.BackgroundTransparency = 1

end

Hope this helps!

Don't forget to accept this if it does!!

1
Wow it works. Thanks for the PlayerGUI info mate! eromusics 10 — 4y
0
No problem! DesertusX 435 — 4y
Ad

Answer this question