Advertisement
FXDuke

FXAdmin 2

Sep 8th, 2022 (edited)
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.80 KB | None | 0 0
  1. -- Set prefix here!
  2.  
  3. --[[
  4.  
  5.  
  6. VERY OUTDATED: VIEW MY PAGE AND SWITCH TO THE CINIMATIC CAMERA TOOL WITH MORE COMMANDS
  7.  
  8.  
  9. ]]
  10. local Prefix = ";";
  11.  
  12. --[[
  13. Commands:
  14. If you have a custom prefix, remember to put it instead of ;!
  15. tp player/displayname
  16. follow player/displayname
  17. view player/displayname
  18. unview
  19. unfollow
  20. ]]
  21.  
  22. -- Locals
  23. local Players = game:GetService("Players");
  24. local Player = Players.LocalPlayer;
  25.  
  26. -- Loop Table
  27. local looped_Commands = {};
  28.  
  29. -- Useless Locals
  30. local view_Name;  -- For console command log
  31.  
  32. -- Lower Functions
  33. local function stc(p1,p2) if string.sub(p1,1,#p2) == string.lower(p2) then return true; end; end; -- String to Command
  34.  
  35. -- Main Functions
  36. local function getPlayer(data)
  37.     local p1 = data:lower();
  38.     for _,p2 in pairs(Players:GetChildren()) do
  39.         local p3 = p2.Name:lower():sub(1,#p1);
  40.         local p4 = p2.DisplayName:lower():sub(1,#p1);
  41.         if p1 == p3 or p1 == p4 then
  42.             return true, p2;
  43.         else
  44.             error("FXAdmin: Player " .. data .. " not found.");
  45.             return false, nil;
  46.         end;
  47.     end;
  48. end;
  49.  
  50. local function Command(data);
  51.     p1 = string.lower(data);
  52.     if stc(p1,prefix .. "tp ") then
  53.         local p2,p3 = getPlayer(string.sub(p1,#(prefix .. "tp ")+1))
  54.         if p2 == true then
  55.             Player.Character.HumanoidRootPart.CFrame = p3.Character.HumanoidRootPart.CFrame;
  56.             return true, "Teleported to " .. p3.Name;
  57.         end;
  58.     elseif stc(p1,prefix .. "follow ") then
  59.         local p2, p3 = getPlayer(string.sub(p1,#(prefix .. "follow ")+1));
  60.         if p2 == true then
  61.             for _,p4 in pairs(looped_Commands) do
  62.                 if p4.Type == "Follow" then
  63.                     table.remove(looped_Commands,_);
  64.                 end;
  65.             end;
  66.             table.insert(looped_Commands, {Type="Follow",Target=p3})
  67.             Player.Character.HumanoidRootPart.CFrame = p3.Character.HumanoidRootPart.CFrame + (p3.Character.HumanoidRootPart.CFrame.lookVector * Vector3.new(-2.5,0,-2.5));
  68.             return true, "Followed " .. p3.Name;
  69.         end;
  70.     elseif stc(p1,prefix .. "unfollow") then
  71.         for _,p2 in pairs(looped_Commands) do
  72.             if p2.Type == "Follow" then
  73.                 table.remove(looped_Commands, _);
  74.                 return true, "Unfollowed " .. p2.Name;
  75.             end;
  76.         end;
  77.     elseif stc(p1,prefix .. "view ") then
  78.         local p2,p3 = getPlayer(string.sub(p1,#(prefix .. "view ")+1));
  79.         if p2 == true then
  80.             workspace.CurrentCamera.CameraSubject = p3.Character:FindFirstChildOfClass("Humanoid") or p3.Character.HumanoidRootPart or p3.Character:FindFirstChildOfClass("BasePart");
  81.             view_Name = p3.Name
  82.             return true, "Viewed " .. p3.Name;
  83.         end;
  84.     elseif stc(p1,prefix .. "unview") then
  85.         workspace.CurrentCamera.CameraSubject = Player.Character:FindFirstChildOfClass("Humanoid") or Player.Character.HumanoidRootPart or Player.Character:FindFirstChildOfClass("BasePart");
  86.         return true, "Unviewed " .. view_Name;
  87.     else
  88.         error("FXAdmin: Command " .. data .. " not found.");
  89.         return false, nil;
  90.     end;
  91. end;
  92.  
  93. -- Listeners
  94. Player.Chatted:Connect(function(data)
  95.     local p1,p2 = Command(data) or nil;
  96.     if p1 == true then
  97.         print("FXAdmin: " .. p2);
  98.     end;
  99. end);
  100.  
  101. -- Main Loop
  102. game:GetService("RunService").Heartbeat:Connect(function(dt)
  103.     for _,p1 in pairs(looped_Commands) do
  104.         if p1.Type == "Follow" then
  105.             if Players:FindFirstChild(p1.Target.Name) or Players:FindFirstChild(p1.Target.DisplayName) then
  106.                 Player.Character.HumanoidRootPart.CFrame = p1.Character.HumanoidRootPart.CFrame + (p1.Character.HumanoidRootPart.CFrame.lookVector * Vector3.new(-2.5,0,-2.5));
  107.             end;
  108.         end;
  109.     end;
  110. end);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement