I made a serverscript that changes the view of the camera. When the script is ran it does not change the cameratype to scriptable and it is not throwing any errors. This script works flawlessly in a localscript but in a localscript the camera will change for all players but with what I'm doing I only want the camera to change for only the player that touched a part.
01 local cam = workspace.Camera 02 local focus = game.Workspace.col1 03 local tween = game:GetService("TweenService") 04 local active = false 05 06 game.Workspace.Shop.Touched:Connect(function(hit) 07 if not active then 08 active = true 09 local humanoid = hit.Parent:FindFirstChild("Humanoid") 10 local player = game.Players:GetPlayerFromCharacter(hit.Parent) 11 local root = hit.Parent:FindFirstChild("HumanoidRootPart") 12 Iterator = 1 13 if humanoid ~= nil then 14 humanoid.WalkSpeed = 0 15 cam.CameraType = Enum.CameraType.Scriptable 16 local ts = TweenInfo.new(0.0001,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0) 17 local Goals = {CFrame = focus.CFrame} 18 local move = tween:Create(cam,ts,Goals) 19 move:Play() 20 if root ~= nil then 21 root.CFrame = game.Workspace.queue.CFrame 22 end 23 wait(0.5) 24 25 local buttons = Instance.new("ScreenGui") 26 local Frame = Instance.new("Frame") 27 local back = Instance.new("ImageButton") 28 local front = Instance.new("ImageButton") 29 local home = Instance.new("TextButton") 30 31 buttons.Name = "buttons" 32 buttons.Parent = player:WaitForChild("PlayerGui") 33 buttons.ZIndexBehavior = Enum.ZIndexBehavior.Sibling 34 35 Frame.Parent = buttons 36 Frame.BackgroundColor3 = Color3.fromRGB(255, 255, 255) 37 Frame.BackgroundTransparency = 1.000 38 Frame.Size = UDim2.new(0, 100, 0, 100) 39 40 back.Name = "back" 41 back.Parent = Frame 42 back.BackgroundColor3 = Color3.fromRGB(0, 0, 0) 43 back.Position = UDim2.new(0, 0, 3.05000019, 0) 44 back.Size = UDim2.new(0, 73, 0, 84) 45 back.Rotation = 180.000 46 back.Image = "http://www.roblox.com/asset/?id=4726772330" 47 back.BackgroundTransparency = 1 48 49 front.Name = "front" 50 front.Parent = Frame 51 front.BackgroundColor3 = Color3.fromRGB(0, 0, 0) 52 front.Position = UDim2.new(11.1300001, 0, 3.05000019, 0) 53 front.Size = UDim2.new(0, 73, 0, 84) 54 front.Image = "http://www.roblox.com/asset/?id=4726772330" 55 front.BackgroundTransparency = 1 56 57 home.Name = "home" 58 home.Parent = Frame 59 home.BackgroundColor3 = Color3.fromRGB(244, 80, 255) 60 home.Position = UDim2.new(4.91000032, 0, 7.48000002, 0) 61 home.Size = UDim2.new(0, 267, 0, 66) 62 home.Font = Enum.Font.SourceSans 63 home.Text = "Back Home" 64 home.TextColor3 = Color3.fromRGB(0, 0, 0) 65 home.TextScaled = true 66 home.TextSize = 14.000 67 home.TextWrapped = true 68 69 player.PlayerGui.buttons.Frame.home.MouseButton1Click:Connect(function(player) 70 cam.CameraType = Enum.CameraType.Custom 71 player.PlayerGui.buttons:Destroy() 72 humanoid.WalkSpeed = 16 73 Iterator = 1 74 end) 75 76 player.PlayerGui.buttons.Frame.front.MouseButton1Click:Connect(function(player) 77 if Iterator <= 4 then 78 Iterator = Iterator + 1 79 local count = tostring(Iterator) 80 local val = "col"..count 81 local focus2 = game.Workspace:WaitForChild(tostring(val)) 82 local ts2 = TweenInfo.new(2,Enum.EasingStyle.Quad,Enum.EasingDirection.In,0,false,0) 83 local Goals2 = {CFrame = focus2.CFrame} 84 local move2 = tween:Create(cam,ts2,Goals2) 85 move2:Play() 86 else 87 Iterator = 0 88 end 89 end) 90 end 91 wait(2) 92 active = false 93 end 94 end)
you can manipulate camera in a localscript only.. because a camera is "local" to a player
Also, to fix the camera changing for all players, for the variable "cam" do
local cam = game:GetService("Workspace").CurrentCamera
wich will get only the player's camera.