Basically when the character dies, i need the screen to of faded into a black, so when the player dies, it doesnt do that, only in studio it works this is the local script:
game.Players.PlayerAdded:Connect(function(player) while true do player.Character.Humanoid.Died:Connect(function() script.Parent.RemoteEvent:FireServer() end) end end)
so it fires the remote event. this is the script
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr) game.ReplicatedStorage.Scripts:Clone().Parent = game.StarterGui game.ReplicatedStorage.ScreenGui:Clone().Parent = game.StarterGui local Screen = Instance.new("ScreenGui", script.Parent.Parent) local Fade = Instance.new("Frame", Screen) local nope = 0 Screen.Enabled = true Fade.Size = UDim2.new(1,0,1,0) Fade.BackgroundColor3 = Color3.fromRGB(0,0,0) Fade.BackgroundTransparency = 2 game.Players.LocalPlayer:WaitForChild("PlayerGui"):SetTopbarTransparency(0) repeat Fade.BackgroundTransparency = Fade.BackgroundTransparency - .1 nope = nope + 1 wait(.01) until nope == 200 nope = 0 end)
fade.Backgroundtransparency is 2 just to give more of a delay, but i have noo idea why it is only working in studio
dude... You are trying to say in your first script... when the player has joined, if he died then fire remote... Alright try this.. from a localscript in startergui
repeat wait() until game.Players.LocalPlayer local char = game.Players.LocalPlayer.Character char:WaitForChild("Humanoid").Died:Connect(function() script.Parent.RemoteEvent:FireServer() end)
Alright this should fire the event when the player dies..
Ok, so here I re-wrote your whole script. Put this into a LocalScript and you should be good to go:
local player = game.Players.LocalPlayer local char = player.Character if char == nil then player.CharacterAdded:Wait() end char = player.Character local playerGui = player.PlayerGui local function fadeBackround() local screen = Instance.new("ScreenGui") screen.Parent = playerGui local fade = Instance.new("Frame") fade.Size = UDim2.new(0,1,0,1) fade.BackgroundColor3 = Color3.fromRGB(0,0,0) fade.BackgroundTransparency = 1 fade.Parent = screen playerGui:SetTopbarTransparency(1) repeat wait(0.01) fade.BackroundTransparency = fade.BackroundTransparency - 0.1 playerGui:SetTopbarTransparency(playerGui:GetTopbarTransparency() - 0.1) until fade.BackroundTransparency <= 0 end char:WaitForChild("Humanoid").Died:Connect(fadeBackround)
And that should be it! Remember, you don't need to use RemoteEvent
s for modifying PlayerGui