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.
01 | game.Players.PlayerAdded:Connect( function (player) |
02 |
03 | -- Detect for leaderstats |
04 |
05 | local leaderstats |
06 |
07 | if player:FindFirstChild( "leaderstats" ) then |
08 | leaderstats = player.leaderstats |
09 | else |
10 | leaderstats = Instance.new( "Folder" ) |
11 | leaderstats.Name = "leaderstats" |
12 | leaderstats.Parent = player |
13 | end |
14 |
15 | -- create deaths value |
1 | -- work in progress |
Hello!
Here is the "screen blackout" script you are looking for. Please note, you are expected to supply the gui yourself.
01 | --localscript inside the gui inside startergui |
02 | local background = script.Parent.Background -- the background that it will fade to black with, can be a textlabel with no text in it |
03 | local text = script.Parent.TextLabel -- the "Failed!" textlabel thing |
04 |
05 | local player = game.Players.LocalPlayer |
06 | local character = player.Character or player.CharacterAdded:Wait() |
07 | local hum = character:WaitForChild( "Humanoid" ) |
08 |
09 | local ts = game:GetService( "TweenService" ) --tweenservice for smooth animations |
10 | local info = TweenInfo.new( 3 ,Enum.EasingStyle.Cubic,Enum.EasingDirection.Out) |
11 | local infotext = TweenInfo.new( 1 ,Enum.EasingStyle.Cubic,Enum.EasingDirection.In) |
12 | --change the 3 to whatever time you want it to delay |
13 | hum.Died:Wait() --waits for the humanoid to die |
14 |
15 | local tween = ts:Create(background,info, { BackgroundTransparency = 0 } ) |
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!