i have this script. its a localscript located inside of replicatedfirst. its supposed to make a screengui become apparent when the localplayer dies, yet it does nothing. nothing in the console shows up.
wait(1) local player = game.Players.LocalPlayer local char = player.Charcter local humanoid = char.Humanoid local fade = game.StarterGui.ScreenGui.Frame.BackgroundTransparency humanoid.Died:Connect(function() fade = 0 end)
The issue I found when testing this was that you created a local variable which directed to a property of an instance, not only that you you are changing the Frame in the StarterGui and not the PlayerGui.
you wrote
local fade = game.StarterGui.ScreenGui.Frame.BackgroundTransparency humanoid.Died:Connect(function() fade = 0 end)
instead it should be:
local fade = player:WaitForChild("PlayerGui").ScreenGui.Frame.BackgroundTransparency humanoid.Died:Connect(function() fade.BackgroundTransparency = 0 end)
By the way, you also misspelled Character
in local char = player.Charcter
so this should work
wait(1) local player = game.Players.LocalPlayer local char = player.Character local humanoid = char.Humanoid local fade = player:WaitForChild("PlayerGui").ScreenGui.Frame.BackgroundTransparency humanoid.Died:Connect(function() fade.BackgroundTransparency = 0 end)
1- You are setting the 'fade' variable to the value of backgroundtransparency. 2- You mispelled Character on line 3 3- You need to change the gui inside of the PlayerGui, not the StarterGui
this can be fixed by setting said variable to the frame instead.
local Server = game:GetService("Players") local Player = Server.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() local fade = Player.PlayerGui.ScreenGui.Frame local function HumanoidDied() fade.BackgroundTransparency = 0 end Character:WaitForChild("Humanoid").Died:Connect(HumanoidDied)