There’s another problem. The expectations are the TextLabel
will show when the Power goes out, but I cannot Parent the TextLabel
.
If you’re trying parent the textlabel outside of the screengui, the textlabel will not show as a result. Why not just edit the properties needed excluding the Parent? But if you do want to Parent the textlabel outside of the screengui, how come .Parent = ExampleHere doesn’t work?
Is this a good way to represent the Parent –
local Sounds = game.ReplicatedStorage["Handler (RS)"].Sounds:WaitForChild("PowerSounds") -- Recognising the Group of Sounds.
Yes. Any style of representing an instance as long it is efficient and correct, it’s a good way.
Where you see -- PowerOutageGui.Visible = true-- Calling the TextLable in PlayerGui
this is where to TextLabel
will be shown.
-- Helper Functions
function SetPowerOut()
for _, Lights in pairs(LightList) do -- Pairing as an instance.
Lights.Bulb.PointLight.Brightness = 0 -- Making the "Lights" Brightness zero (Off).
Lights.Bulb.PointLight.Enabled = false
Lights.Light.Transparency = 1 -- Simply making it that the Neon Part is Transparent.
end
BackgroundSounds.Ambience:Stop() -- BackgroundSound Sound will (Stop) Playing.
Lighting.Atmosphere.Density = 1 -- Creating the Fog pressure level.
Lighting.Atmosphere.Haze = 10 -- Same Here.
LightPart.PointLight.Enabled = true -- Making the Monsters Torso has translucent PointLight when "PowerOutage" is active.
PowerBox.Highlight.Enabled = true
PowerBox.Button.ProximityPrompt.Enabled = true
PowerBox.Button.Color = Color3.new(0, 0, 0)
-- PowerOutageGui.Visible = true -- Calling the TextLable in PlayerGui
PowerState = "Off"
end
for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
if Player:FindFirstChildOfClass("PlayerGui") then
local PowerOutageGui = Player:FindFirstChildOfClass("PlayerGui"):FindFirstChild("PowerOutageGui")
if PowerOutageGui ~= nil then
PowerOutageGui.TextLabel.Visible = true
end
end
end
When the Power turns (Off), the TextLabel
in PowerOutageGui
will show. Then it will fade away, so it isn’t permanent for when the Power is (Off). When the Power is turned (On) the TextLabel
doesn’t show at all. This process will repeat forever until the Player leaves the game.
The TextLabel
will say “Find the Power Box to activate the Power.”
Are you sure you typed in the correct path of the textlabel? Is there something else in the script turning the visibility of the textlabel to false once the power is on? Or is it intentional that it won’t show when the power is on?
The PowerOutageGui
is a ScreenGui
parted way in StarterGui
.
-- PowerOutage Script
local Lighting = game:GetService("Lighting") -- The instance is from Lighting.
local PowerBox = workspace["Handler (W)"].Map.KillArea.PowerOutage.PowerBox
local LightPart = workspace["Handler (W)"].AI.Monster.AIMain.Settings.JumpscareSettings.CameraPart
local Sounds = game.ReplicatedStorage["Handler (RS)"].Sounds:WaitForChild("PowerSounds") -- Recognising the Group of Sounds.
local BackgroundSounds = workspace["Handler (W)"].BackgroundSounds
local Button = workspace["Handler (W)"].Map.KillArea.PowerOutage.PowerBox.Button
local OnSound = Sounds:WaitForChild("PowerOn")
local OffSound = Sounds:WaitForChild("PowerOff")
-- local ChargeSound = Part:WaitForChild("ChargeSound")
local ProximityPrompt = Button:WaitForChild("ProximityPrompt")
local Cooldown = false
local Duration = 55 -- Duration in Seconds.
local PowerState = "On"
-- Getting the List of Lights
local LightList = {}
for _, Lights in pairs(workspace["Handler (W)"].Map.KillArea.Lights:GetDescendants()) do
if Lights:IsA("Model") and Lights.Name == "LightBulb" then
table.insert(LightList,Lights)
end
end
for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
if Player:FindFirstChildOfClass("PlayerGui") then
local PowerOutageGui = Player:FindFirstChildOfClass("PlayerGui"):FindFirstChild("PowerOutageGui")
if PowerOutageGui ~= nil then
PowerOutageGui.TextLabel = false
end
end
end
-- Helper Functions
function SetPowerOn()
for _, Lights in pairs(LightList) do -- Pairing as an instance.
Lights.Bulb.PointLight.Brightness = 1 -- Making the "Lights" Brightness 1 (On).
Lights.Bulb.PointLight.Enabled = true
Lights.Light.Transparency = 0 -- Simply making it that the Neon Part is Transparent.
end
BackgroundSounds.Ambience:Play() -- BackgroundSound Sound will (Start).
Lighting.Atmosphere.Density = 0 -- Disabling the Fog pressure level.
Lighting.Atmosphere.Haze = 0 -- Same Here.
LightPart.PointLight.Enabled = false -- Making the Monsters Torso has Non-translucent PointLight when "PowerOutage" is inactive.
PowerBox.Highlight.Enabled = false
PowerBox.Button.ProximityPrompt.Enabled = false
PowerBox.Button.Color = Color3.new(0, 161, 0)
-- PowerOutageGui.Visible = false -- Calling the TextLable in PlayerGui
PowerState = "On"
end
function SetPowerOut()
for _, Lights in pairs(LightList) do -- Pairing as an instance.
Lights.Bulb.PointLight.Brightness = 0 -- Making the "Lights" Brightness zero (Off).
Lights.Bulb.PointLight.Enabled = false
Lights.Light.Transparency = 1 -- Simply making it that the Neon Part is Transparent.
end
BackgroundSounds.Ambience:Stop() -- BackgroundSound Sound will (Stop) Playing.
Lighting.Atmosphere.Density = 1 -- Creating the Fog pressure level.
Lighting.Atmosphere.Haze = 10 -- Same Here.
LightPart.PointLight.Enabled = true -- Making the Monsters Torso has translucent PointLight when "PowerOutage" is active.
PowerBox.Highlight.Enabled = true
PowerBox.Button.ProximityPrompt.Enabled = true
PowerBox.Button.Color = Color3.new(0, 0, 0)
-- PowerOutageGui.Visible = true -- Calling the TextLable in PlayerGui
PowerState = "Off"
end
ProximityPrompt.Triggered:Connect(function()
-- ChargeSound:Play()
OnSound:Play()
OffSound:Stop()
SetPowerOn()
end)
SetPowerOn()
while true do
task.wait(Duration)
OffSound:Play()
OnSound:Stop()
SetPowerOut()
while (PowerState == "Off") do
task.wait()
end
end
.TextLabel = false
Did you forget to type .Visible? If you want the textlabel to show once the power is on again why not put another one in the function that sets the power to on. Does this fix your issue?
I only want the TextLabel
to show when the Power turns (Off).
Then just put this in the function named “SetPowerOut()”:
Then also put this in the SetPowerOn function:
for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
if Player:FindFirstChildOfClass("PlayerGui") then
local PowerOutageGui = Player:FindFirstChildOfClass("PlayerGui"):FindFirstChild("PowerOutageGui")
if PowerOutageGui ~= nil then
PowerOutageGui.TextLabel.Visible = false
end
end
end
@yesimrealll
this worked.
-- Getting the PowerOuatageGui in PlayerGui.
for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
if Player:FindFirstChildOfClass("PlayerGui") then
local PowerOutage = Player:FindFirstChildOfClass("PlayerGui"):FindFirstChild("PowerOutageGui"):FindFirstChildOfClass("TextLabel")
if PowerOutage ~= nil then
PowerOutage.Visible = false
end
end
end
Would I have to add two of the same tables but one functions Power(On) and the other functions Power(Off)?
@yesimrealll
Can I do this…?
-- PowerOutage Script
local Lighting = game:GetService("Lighting") -- The instance is from Lighting.
local PowerBox = workspace["Handler (W)"].Map.KillArea.PowerOutage.PowerBox
local LightPart = workspace["Handler (W)"].AI.Monster.AIMain.Settings.JumpscareSettings.CameraPart
local Sounds = game.ReplicatedStorage["Handler (RS)"].Sounds:WaitForChild("PowerSounds") -- Recognising the Group of Sounds.
local BackgroundSounds = workspace["Handler (W)"].BackgroundSounds
local Button = workspace["Handler (W)"].Map.KillArea.PowerOutage.PowerBox.Button
local OnSound = Sounds:WaitForChild("PowerOn")
local OffSound = Sounds:WaitForChild("PowerOff")
-- local ChargeSound = Part:WaitForChild("ChargeSound")
local ProximityPrompt = Button:WaitForChild("ProximityPrompt")
local Cooldown = false
local Duration = 55 -- Duration in Seconds.
local PowerState = "On"
-- Getting the List of Lights.
local LightList = {}
for _, Lights in pairs(workspace["Handler (W)"].Map.KillArea.Lights:GetDescendants()) do
if Lights:IsA("Model") and Lights.Name == "LightBulb" then
table.insert(LightList,Lights)
end
end
-- Getting the PowerOuatageGui in PlayerGui.
for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
if Player:FindFirstChildOfClass("PlayerGui") then
local PowerOutage = Player:FindFirstChildOfClass("PlayerGui"):FindFirstChild("PowerOutageGui"):FindFirstChildOfClass("TextLabel")
if PowerOutage ~= nil then
PowerOutage.Visible = false
-- Helper Functions.
function SetPowerOn()
for _, Lights in pairs(LightList) do -- Pairing as an instance.
Lights.Bulb.PointLight.Brightness = 1 -- Making the "Lights" Brightness 1 (On).
Lights.Bulb.PointLight.Enabled = true
Lights.Light.Transparency = 0 -- Simply making it that the Neon Part is Transparent.
end
BackgroundSounds.Ambience:Play() -- BackgroundSound Sound will (Start).
Lighting.Atmosphere.Density = 0 -- Disabling the Fog pressure level.
Lighting.Atmosphere.Haze = 0 -- Same Here.
LightPart.PointLight.Enabled = false -- Making the Monsters Torso has Non-translucent PointLight when "PowerOutage" is inactive.
PowerBox.Highlight.Enabled = false
PowerBox.Button.ProximityPrompt.Enabled = false
PowerBox.Button.Color = Color3.new(0, 161, 0)
PowerOutage.Visible = false
PowerState = "On"
end
function SetPowerOut()
for _, Lights in pairs(LightList) do -- Pairing as an instance.
Lights.Bulb.PointLight.Brightness = 0 -- Making the "Lights" Brightness zero (Off).
Lights.Bulb.PointLight.Enabled = false
Lights.Light.Transparency = 1 -- Simply making it that the Neon Part is Transparent.
end
BackgroundSounds.Ambience:Stop() -- BackgroundSound Sound will (Stop) Playing.
Lighting.Atmosphere.Density = 1 -- Creating the Fog pressure level.
Lighting.Atmosphere.Haze = 10 -- Same Here.
LightPart.PointLight.Enabled = true -- Making the Monsters Torso has translucent PointLight when "PowerOutage" is active.
PowerBox.Highlight.Enabled = true
PowerBox.Button.ProximityPrompt.Enabled = true
PowerBox.Button.Color = Color3.new(0, 0, 0)
PowerOutage.Visible = true
PowerState = "Off"
ProximityPrompt.Triggered:Connect(function()
-- ChargeSound:Play()
OnSound:Play()
OffSound:Stop()
SetPowerOn()
end)
SetPowerOn()
while true do
task.wait(Duration)
OffSound:Play()
OnSound:Stop()
SetPowerOut()
while (PowerState == "Off") do
task.wait()
end
end
end
end
end
end
It seems like it. But make a backup of your script before testing it out. You might lose a lot of progress if you can’t undo it.
I only just realized it doesn’t work.