Advertisement
DrawingJhon

Show Camera

Sep 4th, 2021
1,665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.46 KB | None | 0 0
  1. local players = game:GetService("Players")
  2. local network = game:GetService("NetworkServer")
  3.  
  4. local model = Instance.new("Model")
  5. model.Name = "Cameras"
  6. model.Parent = script
  7.  
  8. local Cameras = {}
  9.  
  10. local function setup(plr)
  11.     local cam = Instance.new("Part")
  12.     Cameras[plr.UserId] = cam
  13.     cam.Name = plr.Name.."_Camera"
  14.     cam.Anchored = true
  15.     cam.Size = Vector3.new(1, 1, 2)
  16.     cam.TopSurface = "Smooth"
  17.     cam.BottomSurface = "Smooth"
  18.     cam.FrontSurface = "Hinge"
  19.     cam.Color = Color3.new(1,1,1)
  20.     cam.Transparency = 0.3
  21.     cam.CanCollide = false
  22.     cam.Locked = true
  23.     local bg = Instance.new("BillboardGui", cam)
  24.     bg.Adornee = cam
  25.     bg.AlwaysOnTop = true
  26.     bg.DistanceUpperLimit = -1
  27.     bg.MaxDistance = math.huge
  28.     bg.Size = UDim2.new(3, 0, 1.5, 0)
  29.     bg.StudsOffset = Vector3.new(0.5, 2.6, 0)
  30.     local tb = Instance.new("TextLabel", bg)
  31.     tb.BackgroundColor3 = Color3.new(1, 1, 1);
  32.     tb.BackgroundTransparency = 1;
  33.     tb.BorderColor3 = Color3.fromRGB(27, 42, 53);
  34.     tb.BorderSizePixel = 1;
  35.     tb.Position = UDim2.new(-0.17, -20, 0, 0);
  36.     tb.Size = UDim2.new(1, 40, 0.9, -1);
  37.     tb.Font = "SourceSansBold";
  38.     tb.LineHeight = 1;
  39.     tb.Text = plr.Name.."'s camera"
  40.     tb.TextColor3 = Color3.new(1, 1, 1);
  41.     tb.TextScaled = true;
  42.     tb.TextStrokeColor3 = Color3.fromRGB(20, 20, 20);
  43.     tb.TextStrokeTransparency = 0.5;
  44.     tb.TextWrapped = true;
  45.     tb.TextYAlignment = "Bottom";
  46.     cam.Parent = model
  47.     local sec = Instance.new("ScreenGui")
  48.     sec.ResetOnSpawn = false
  49.     sec.Name = "Camera Sender"
  50.     sec.Parent = plr:findFirstChildOfClass("PlayerGui")
  51.     local client = NLS([==[
  52.     local remote = script:WaitForChild("CFrameSender")
  53.     local obj = script:WaitForChild("Camera").Value
  54.     obj:Destroy()
  55.     game:GetService("RunService").Stepped:Connect(function()
  56.         local cam = workspace.CurrentCamera
  57.         if cam then
  58.             remote:FireServer(cam.CFrame)
  59.         end
  60.     end)
  61.     ]==], sec)
  62.     local remote = Instance.new("RemoteEvent")
  63.     remote.Name = "CFrameSender"
  64.     remote.OnServerEvent:Connect(function(p, cf)
  65.         if p == plr and typeof(cf) == "CFrame" then
  66.             cam.CFrame = cf
  67.         end
  68.     end)
  69.     local obj = Instance.new("ObjectValue")
  70.     obj.Value = cam
  71.     obj.Name = "Camera"
  72.     obj.Parent = client
  73.     remote.Parent = client
  74.  
  75. end
  76.  
  77. for i, v in pairs(players:GetPlayers()) do
  78.     setup(v)
  79. end
  80. players.PlayerAdded:Connect(setup)
  81.  
  82. network.DescendantRemoving:Connect(function(client)
  83.     pcall(function()
  84.         local plr = client:GetPlayer()
  85.         local cam = Cameras[plr.UserId]
  86.         if cam then
  87.             cam:Destroy()
  88.             Cameras[plr.UserId] = nil
  89.         end
  90.     end)
  91. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement