My remote event won't work

So basically what I am trying to do is create a remote event that would immediately trigger a white screen but, it doesn’t work. This is the server script:

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function()
		if game.Workspace.Game.Variables.Explosion.Value == true then
			game.ReplicatedStorage.ImmediateExplosionScreen:FireClient(player)
		end
	end)
end)

The explosion value gets changed on true but when it is true it doesn’t work either way…
and this is the client one:

game.ReplicatedStorage.ImmediateExplosionScreen.OnClientEvent:Connect(function()
	script.Parent.BackgroundTransparency = 0
end)

and it has another code above it. For some reason it won’t set the transparency to 0…

In what script do you change the Explosion’s Value to true?

This is in a LocalScript in a GUI? Do GUIs reset on death? If so, it’s likely that your event is firing before the GUI loads. This is only a problem because the event only fires when the character respawns. Is that intentional? If it’s not intentional and you want the event to be fired whenever Explosion.Value is changed, do this.

game.Workspace.Game.Variables.Explosion.Changed:Connect(function(value)
    if value then
        game.ReplicatedStorage.ImmediateExplosionScreen:FireAllClients()
    end
end)

If you do indeed only want the event to fire when the player respawns, you’ll need to wait a few seconds before firing it, or better yet get rid of the server script altogether and do this in the LocalScript:

if game.Workspace.Game.Variables.Explosion.Value then
    script.Parent.BackgroundTransparency = 0
end

Or, if GUIs don’t reset on death and you only want the event to be fired upon respawning, let me know and we’ll keep working it out.

I just want the screen to turn white when the player resets to make sure they don’t abuse it by respawning…

Then refer to this.

Let me know if that doesn’t work, but I’ll be away from keyboard for a few hours.

It didn’t, I already tried before

Using this code in a LocalScript in StarterGui:

print("Runs on respawn")
print("Explosion.Value is", workspace.Game.Variables.Explosion.Value)
if game.Workspace.Game.Variables.Explosion.Value then
    print("Setting transparency")
    script.Parent.BackgroundTransparency = 0
end

What prints when you respawn?

have you tried using a print statement in your function to see if that works?

I tried doing it like this. I did

game.Players.LocalPlayer.CharacterAdded(function()
if game.Workspace.Game.Variables.Explosion.Value then
    print("Setting transparency")
    script.Parent.BackgroundTransparency = 0
end
end)

and tried to print it but didn’t work

Actually it does print setting transparency but it doesn’t actually do so…