You mentioned that it was a regular script in a Frame...
Before I share my answer I'll share with you an experience i had with doing the same thing:
When I click on a part, a gui (The frame) is supposed to pop up... however it pops up only ONCE. After I closed it, it never pops up again. I think the logic is the same behind this.
Therefore, I used RemoteEvents and put the script in a local script instead, and it worked perfectly fine after that.
I have a way out here that (possibly) works
[[EDIT]]after the comments:
you mentioned that the real problem is really only about the Gui and the transparency not working.
that is because your old script was a Server-sided script inside a Frame. This cannot be used to change the transparency of the frame, as changing the transparency of a Frame would require a LocalScript. That's why we use the RemoteEvents to detect whether the oxygen breaking etc. changed
this is the server sided script in the workspace
local OxGenPlrDying = workspace.OxGenPlrDying
local OxGenIsOnAction = workspace.OxGenIsOnAction
local OxGenPlrHealing = workspace.OxGenPlrHealing
local RE = game:GetService("ReplicatedStorage").RemoteEvent
OxGenPlrDying:GetPropertyChangedSignal("Value"):Connect(function()
RE:FireAllClients(OxGenPlrDying.Value,OxGenIsOnAction.Value,OxGenPlrHealing.Value)
OxGenIsOnAction:GetPropertyChangedSignal("Value"):Connect(function()
RE:FireAllClients(OxGenPlrDying.Value,OxGenIsOnAction.Value,OxGenPlrHealing.Value)
OxGenPlrHealing:GetPropertyChangedSignal("Value"):Connect(function()
RE:FireAllClients(OxGenPlrDying.Value,OxGenIsOnAction.Value,OxGenPlrHealing.Value)
end)
The local script in the frame:
local function changeBackgroundTransparency(your_parameters)
repeat
wait(0.001)
if game.Workspace.OxGenPlrDying.Value==true then
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency-0.0001
if game.Workspace.OxGenRestartComplete.Value==true then
game.Workspace.OxGenPlrDying.Value=false
game.Workspace.OxGenPlrHealing.Value=true
end
elseif game.Workspace.OxGenPlrHealing.Value==true then
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency+0.01
if script.Parent.BackgroundTransparency==1 then
game.Workspace.OxGenPlrHealing.Value=false
end
end
until script.Parent.BackgroundTransparency = 1
end
RE.OnClientEvent:Connect(function(your_parameters)
changeBackgroundTransparency(your_parameters)
end)
So the logic here is that when oxygen level change, you fire the remote event which triggers the background transparency. it'll keep repeating the decrease/increase of background transparency until it gets the desired level.
i hope this was what you meant by your main problem
[ EDIT 2 ]
This is the first script, local script in the frame
local RE = game:GetService("ReplicatedStorage").RemoteEvent
local function changeBackgroundTransparency(OxGenPlrDying,OxGenRestartComplete)
while wait(0.001) do
if OxGenPlrDying==true then
print("Player Dying")
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency-0.0001
if OxGenRestartComplete==true then
OxGenPlrDying.Value=false
end
elseif OxGenPlrDying==false then
print("Player Healing")
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency+0.01
if script.Parent.BackgroundTransparency==1 then
end
end
end
RE.OnClientEvent:Connect(function(OxGenPlrDying,OxGenRestartComplete)
changeBackgroundTransparency(OxGenPlrDying,OxGenRestartComplete)
end)
end
Your second script should be fine.
For the third script, any particular reason to disable it? How are you going to enable it after disabling it?
[EDIT 3]
The second script, I edited it a bit.
local OxGenPlrDying = workspace.OxGenPlrDying
local OxGenIsOnAction = workspace.OxGenIsOnAction
local OxGenRestartComplete = workspace.OxGenRestartComplete
local RE = game:GetService("ReplicatedStorage").RemoteEvent
OxGenPlrDying:GetPropertyChangedSignal("Value"):Connect(function()
RE:FireAllClients(OxGenPlrDying.Value,OxGenRestartComplete.Value)
end)
OxGenRestartComplete:GetPropertyChangedSignal("Value"):Connect(function()
RE:FireAllClients(OxGenPlrDying.Value,OxGenRestartComplete.Value)
end)
OxGenIsOnAction:GetPropertyChangedSignal("Value"):Connect(function()
RE:FireAllClients(OxGenPlrDying.Value,OxGenRestartComplete.Value)
end)
[EDIT 4] I edited your first script a little more. I reckon the problem should be in here since it didn't print out what's necessary.
local RE = game:GetService("ReplicatedStorage").RemoteEvent
RE.OnClientEvent:Connect(function(OxGenPlrDying,OxGenRestartComplete)
while wait(0.001) do
if OxGenPlrDying==true then
print("Player Dying")
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency-0.0001
if OxGenRestartComplete==true then
OxGenPlrDying.Value=false
end
elseif OxGenPlrDying==false then
print("Player Healing")
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency+0.01
if script.Parent.BackgroundTransparency==0 or script.Parent.BackgroundTransparency==1 then break
end
end
end
end)
[EDIT 5]
I further edited your first script. Hopefully this works a bit better. Also sorry for the really late reply, was quite busy
local RE = game:GetService("ReplicatedStorage").RemoteEvent
RE.OnClientEvent:Connect(function(OxGenPlrDying,OxGenRestartComplete)
while wait(0.001) do
if OxGenPlrDying==true then
print("Player Dying")
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency-0.0001
if OxGenRestartComplete==true then
OxGenPlrDying.Value=false
end
elseif OxGenPlrDying==false then
print("Player Healing")
end
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency+0.01
if script.Parent.BackgroundTransparency==0 or script.Parent.BackgroundTransparency==1 then break
end
end
end)
[EDIT 6]
Well this seems pretty challenging to me. None of the above solutions really worked... no really sure if this will now. To be honest i don't know why Player Dying and Player Healing keep printing... the only reason for that is that the BoolValue keeps alternating between false and true.
At this point, really the only way is to keep trying different methods of writing your script
add a remotefunction called "RemoteFunction" to your replicated storage and try this!
your first script (local script): warning this may cause lag but hopefully it doesn't
local RE = game:GetService("ReplicatedStorage").RemoteEvent
local RF = game:GetService("ReplicatedStorage").RemoteFunction
RE.OnClientEvent:Connect(function(OxGenPlrDying)
while wait(0.001) do
if OxGenPlrDying==true then
print("Player Dying")
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency-0.0001
if workspace.OxGenRestartComplete.Value == true then
RF:InvokeServer()
end
elseif OxGenPlrDying==false then
print("Player Healing")
script.Parent.BackgroundTransparency=script.Parent.BackgroundTransparency+0.01
end
if script.Parent.BackgroundTransparency==0 or script.Parent.BackgroundTransparency==1 then break
end
end
end)
in another new script [Script 4] a Server-Sided-Script in Server-Script-Service:::::::
local RF = game:GetService("ReplicatedStorage").RemoteFunction
RF.OnServerInvoke = function()
workspace.OxGenPlrDying.Value = false
end
i'm actually quite confident that this will work now lol, if it still doesn't that would be quite sad xD.
i deleted the first draft because when i tried to edit it said :
"Whoa there! That's some awful long text. Please stay below 10,000 characters!
"
11 comments
was it a local script?
Nope. It was a regular script.
hmm... about the oxygen level change, how often does it change from true to false or false to true?
and also, when the oxygen level change does it change for all players?
if so you can consider using :GetPropertyChangedSignal() instead
Does the value change actually work for all players?
so I have an oxygen generator and it gets broken in random minutes. When it's broken, someone should restart it in 80 seconds or it'll kick everyone in the server. During the moment while it's broken, everybody's screen goes slowly red and when someone restarts it successfully, the red Frame that I'm talking about rapidly fades out.
and after someone fix the generator, the loop starts all over again and the loop lasts forever. But the problem is, the script which increases/decreases the Frame transparency only works once.
the logic is basically when the Generator goes into a malfunction, oxygen level inside the submarine decreases every second and it makes everyone's screen turn into red slowly because they're losing oxygen. When it's completely red, it means you're drowned and then it kicks everyone in the server (after 80 seconds). And yes, it affects everyone. I hope I explained well!
As our friend GameStealerKid asked, can you please provide the full code?
aight check my answer now