Jaidenbbb3

Allowed Car Access Script

Oct 8th, 2025
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | Source Code | 0 0
  1. local allowedUsernames = {"PamPam4021"}
  2. local vehicleSeat = script.Parent
  3.  
  4. vehicleSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
  5.     local occupant = vehicleSeat.Occupant
  6.     if occupant then
  7.         local humanoid = occupant
  8.         local player = game.Players:GetPlayerFromCharacter(humanoid.Parent)
  9.  
  10.         if player then
  11.             -- ✅ Only punish if player is NOT allowed
  12.             if not table.find(allowedUsernames, player.Name) then
  13.                 local message = Instance.new("Message")
  14.                 message.Parent = workspace
  15.                 message.Text = "You're not allowed in this vehicle.."
  16.                 task.wait(1)
  17.                 message:Destroy()
  18.  
  19.                 humanoid.Health = 0
  20.             end
  21.         end
  22.     end
  23. end)
  24.  
Tags: Script Code
Advertisement
Add Comment
Please, Sign In to add comment