Basically, in my game I want it to make it so every time you die the screen goes black and says like FAILED and adds one death to the leaderboard. The thing is, I have NO IDEA how to do it. I also want to make the screen a bit darker the entire time you're playing. Can someone help? The only thing I've done so far is put the camera in first person lock.
Here how you can make a death counter on the leaderboard. Put this script in ServerScriptService.
game.Players.PlayerAdded:Connect(function(player) -- Detect for leaderstats local leaderstats if player:FindFirstChild("leaderstats") then leaderstats = player.leaderstats else leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player end -- create deaths value local deaths = Instance.new("IntValue") deaths.Name = "Deaths" deaths.Parent = leaderstats -- detect character added. player.CharacterAdded:Connect(function(char) -- detect humanoid died. char.Humanoid.Died:Connect(function() deaths.Value = deaths.Value + 1 -- add 1 value to values end) end) end)
-- work in progress
Hello!
Here is the "screen blackout" script you are looking for. Please note, you are expected to supply the gui yourself.
--localscript inside the gui inside startergui local background = script.Parent.Background -- the background that it will fade to black with, can be a textlabel with no text in it local text = script.Parent.TextLabel -- the "Failed!" textlabel thing local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local hum = character:WaitForChild("Humanoid") local ts = game:GetService("TweenService") --tweenservice for smooth animations local info = TweenInfo.new(3,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out) local infotext = TweenInfo.new(1,Enum.EasingStyle.Cubic,Enum.EasingDirection.In) --change the 3 to whatever time you want it to delay hum.Died:Wait() --waits for the humanoid to die local tween = ts:Create(background,info,{BackgroundTransparency = 0}) tween:Play() tween.Completed:Wait() wait(0.5) local tween = ts:Create(text, infotext,{TextTransparency = 0}) tween:Play() tween.Completed:Wait()
This also doubles as the "screen darker the entire time" because you can set the background gui to something like 0.8 backgroundtransparency.
I hope this helped.
If you have any questions, ask them below!