You see, I wanted a way to make it so that if you own a specific badge, you can open a door. And if you don't own it, you are killed. I've been trying for ages, but I also have a question; can the door be part of a group?
You can use BadgeService’s :UserHasBadge()
method to validate whether the given Player has the given Badge. This function return a Boolean value which means we can call it directly in a conditional.
local BadgeService = game:GetService("BadgeService") local BadgeId = --// Badge Asset ID local Player = game:GetService("Players").LocalPlayer if (BadgeService:UserHasBadge(Player.UserId, BadgeId) then --// Code end
local door = workspace:WaitForiChild("") -- Insert the door's name here local BadgeService = game:GetService("BadgeService") local BadgeId -- = // Badge Asset Id local Player = game:GetService("Players").LocalPlayer local debounce = false local debounce2 = false if (BadgeService:UserHasBadge(Player.UserId, BadgeId)) then door.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and debounce == false then debounce = true for i = 1,10,1 do door.Transparency = door.Transparency+(0.1) end wait() door.CanCollide = false wait(3) for i = 1,10,1 do door.Transparency = door.Transparency-(0.1) end wait() door.CanCollide = true debounce = false end end) else door.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") and debounce2 == false then debounce2 = true hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 100 wait() debounce2 = false end end) end