Death amount door

Anybody have a script that you put in a brick which allows players to go into a brick only if they have a specific amount of deaths?

Like a door you can only enter when you have a specific death amount.

Sorry I am new to scripting and I try to not ask a lot

Do you have anything that keeps track of deaths? It’s easy to script everything into one, but if you’re already keeping track of deaths elsewhere, or if you plan on reusing this (multiple doors), it would be better to understand some specifics first.

What you can do is store the number of deaths in an IntValue using a Data Store. After that, you can put this script inside the door.

local Door = script.Parent
local requiredDeaths = 10 -- Amount of deaths the player needs to open the door.
local timeOpened = 2 -- Seconds that the door will be opened.

Door.Touched:Connect(function(hit)
 local humanoid = hit.Parent:FindFirstChild("Humanoid")
 if humanoid ~= nil then
  local Players = game:FindService("Players")
  local plr = Players:GetPlayerFromCharacter(humanoid.Parent)
  if plr.leaderstats:WaitForChild("Deaths").Value >= requiredDeaths then
   Door.CanCollide = false
   wait(timeOpened)
   Door.CanCollide = true
  end
 end
end)

There is usually a better approach to this, but I am lazy so the door isn’t going to be the fanciest. Hope this helps.

2 Likes

Great start, but we don’t know if they are keeping track of deaths through a leaderstat named “Deaths”

Also, leaderstats aren’t data stores. Here’s the right page for what you’re using: Documentation - Roblox Creator Hub

1 Like

Yeah, I just gave them a pointer, all they have to do is ask. Also, thanks for the correction on the link.

1 Like