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 5 years ago
1game.StarterGui.health.white.BackgroundTransparency = 1
2game.StarterGui.health.white.red.BackgroundTransparency = 1
3game.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
5 years ago
Edited 5 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.

01local players = game.Players:GetPlayers() --Setting out a table of the players.
02 
03for _,player in pairs(players) do --Looping through each player in the game
04 
05    local playerGui = player:WaitForChild("PlayerGui") --Defining a variable for the PlayerGui
06 
07        playerGui.health.white.BackgroundTransparency = 1
08        playerGui.health.white.red.BackgroundTransparency = 1
09        playerGui.health.white.red.green.BackgroundTransparency = 1
10 
11end

Hope this helps!

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

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

Answer this question