Hello guys, I'm hoping that you can help me here. I've been trying to figure out what is wrong with this script but I cannot find anything. It is supposed to check if my Rank does not have enough permissions to open the door it's supposed to kill the player but instead it kills me no matter what my Rank is. Please see code below if I didn't make sense here. Any help appreciated.
Scanning = false function Scan(hit) if Scanning == false then Scanning = true if hit.Parent:FindFirstChild("Humanoid") then local Player = game.Players[hit.Parent.Name] if Player:WaitForChild('leaderstats').Rank.Value == 'Hotel Guest' or 'Suspended' or 'Noted Guest' or 'Trainee' or 'Receptionist' or 'Senior Receptionist' then print("\\ACCESS RESTRICTED\\ ~~ "..Player.Name) local Gui = game.ServerStorage.AccessDenied:Clone() Gui.Parent = Player.PlayerGui Player.Character.Humanoid.WalkSpeed = 0 wait(1) Player.Character.Humanoid.Health = 0 wait(2) Scanning = false else Scanning = false end else Scanning = false end else end end script.Parent.Touched:connect(Scan)
You'd have to write if Player:WaitForChild('leaderstats').Rank.Value == 'Hotel Guest' for every name. You can't say or and then the name; that translates to is "Suspended" true or is "HotelGuest" true, which doesn't mean anything to the script as that's just a string.
local Scanning = false -- A dictionary type of table will help keep -- you ordered when you have a lot of things to check against. local RestrictedRanks = { ['Hotel Guest'] = true; ['Suspended'] = true; ['Noted Guest'] = true; ['Trainee'] = true; ['Receptionist'] = true; ['Senior Receptionist'] = true } function Scan(hit) if Scanning == false then Scanning = true if hit and hit.Parent then local Player = game.Players:GetPlayerFromCharacter(hit.Parent) if Player then local hum = Player.Character:findFirstChild("Humanoid") if not hum then return end local leaderstats = Player:WaitForChild("leaderstats") if leaderstats then local rank = leaderstats.Rank if RestrictedRanks[rank.Value] then -- Search for rank in table print("\\ACCESS RESTRICTED\\ ~~ "..Player.Name) local Gui = game.ServerStorage.AccessDenied:Clone() Gui.Parent = Player.PlayerGui hum.WalkSpeed = 0 wait(1) hum.Health = 0 wait(2) Scanning = false else Scanning = false end else Scanning = false end end end end end script.Parent.Touched:connect(Scan)