Upscalefanatic3

(Roblox) Chat command Doors [Learners]

Apr 3rd, 2020
199
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Script by lnsertYourself
  2. local whitelist = {"alwaysbloo", "lnsertYourself"}
  3. local openCommand = "!open"
  4. local closeCommand = "!close"
  5. local fadeLength = 1
  6.  
  7. --// DO NOT MODIFY BEYOND THIS POINT \\--
  8. local tweenService = game:GetService("TweenService")
  9. local tweenInfo = TweenInfo.new(fadeLength, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false ,0)
  10.  
  11. game.Players.PlayerAdded:Connect(function(player)
  12.     if table.find(whitelist, player.Name) then
  13.         -- Player is whitelisted to use commands
  14.         player.Chatted:Connect(function(message)
  15.             if string.sub(message, 1,5) == openCommand then
  16.                 -- Open command
  17.                 local door = workspace:FindFirstChild(string.sub(message, 7))
  18.                 if door then
  19.                     -- Door to open found
  20.                     local tween = tweenService:Create(door, tweenInfo, {Transparency = 1})
  21.                     tween:Play()
  22.                     tween.Completed:Wait()
  23.                     door.CanCollide = false
  24.                 end
  25.             elseif string.sub(message, 1,6) == closeCommand then
  26.                 -- Close command
  27.                 local door = workspace:FindFirstChild(string.sub(message, 8))
  28.                 if door then
  29.                     -- Door to close found
  30.                     local tween = tweenService:Create(door, tweenInfo, {Transparency = 0}):Play()
  31.                     door.CanCollide = true
  32.                 end
  33.             end
  34.         end)
  35.     end
  36. end)
RAW Paste Data