Why is my CameraType not changing in my serverscript?
Asked by
5 years ago Edited 5 years ago
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 | 01 local cam = workspace.Camera |
02 | 02 local focus = game.Workspace.col 1 |
03 | 03 local tween = game:GetService( "TweenService" ) |
04 | 04 local active = false |
06 | 06 game.Workspace.Shop.Touched:Connect( function (hit) |
09 | 09 local humanoid = hit.Parent:FindFirstChild( "Humanoid" ) |
10 | 10 local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
11 | 11 local root = hit.Parent:FindFirstChild( "HumanoidRootPart" ) |
13 | 13 if humanoid ~ = nil then |
14 | 14 humanoid.WalkSpeed = 0 |
15 | 15 cam.CameraType = Enum.CameraType.Scriptable |
16 | 16 local ts = TweenInfo.new( 0.0001 ,Enum.EasingStyle.Quad,Enum.EasingDirection.In, 0 , false , 0 ) |
17 | 17 local Goals = { CFrame = focus.CFrame } |
18 | 18 local move = tween:Create(cam,ts,Goals) |
21 | 21 root.CFrame = game.Workspace.queue.CFrame |
25 | 25 local buttons = Instance.new( "ScreenGui" ) |
26 | 26 local Frame = Instance.new( "Frame" ) |
27 | 27 local back = Instance.new( "ImageButton" ) |
28 | 28 local front = Instance.new( "ImageButton" ) |
29 | 29 local home = Instance.new( "TextButton" ) |
31 | 31 buttons.Name = "buttons" |
32 | 32 buttons.Parent = player:WaitForChild( "PlayerGui" ) |
33 | 33 buttons.ZIndexBehavior = Enum.ZIndexBehavior.Sibling |
35 | 35 Frame.Parent = buttons |
36 | 36 Frame.BackgroundColor 3 = Color 3. fromRGB( 255 , 255 , 255 ) |
37 | 37 Frame.BackgroundTransparency = 1.000 |
38 | 38 Frame.Size = UDim 2. new( 0 , 100 , 0 , 100 ) |
42 | 42 back.BackgroundColor 3 = Color 3. fromRGB( 0 , 0 , 0 ) |
43 | 43 back.Position = UDim 2. new( 0 , 0 , 3.05000019 , 0 ) |
44 | 44 back.Size = UDim 2. new( 0 , 73 , 0 , 84 ) |
45 | 45 back.Rotation = 180.000 |
47 | 47 back.BackgroundTransparency = 1 |
49 | 49 front.Name = "front" |
50 | 50 front.Parent = Frame |
51 | 51 front.BackgroundColor 3 = Color 3. fromRGB( 0 , 0 , 0 ) |
52 | 52 front.Position = UDim 2. new( 11.1300001 , 0 , 3.05000019 , 0 ) |
53 | 53 front.Size = UDim 2. new( 0 , 73 , 0 , 84 ) |
55 | 55 front.BackgroundTransparency = 1 |
59 | 59 home.BackgroundColor 3 = Color 3. fromRGB( 244 , 80 , 255 ) |
60 | 60 home.Position = UDim 2. new( 4.91000032 , 0 , 7.48000002 , 0 ) |
61 | 61 home.Size = UDim 2. new( 0 , 267 , 0 , 66 ) |
62 | 62 home.Font = Enum.Font.SourceSans |
63 | 63 home.Text = "Back Home" |
64 | 64 home.TextColor 3 = Color 3. fromRGB( 0 , 0 , 0 ) |
65 | 65 home.TextScaled = true |
66 | 66 home.TextSize = 14.000 |
67 | 67 home.TextWrapped = true |
69 | 69 player.PlayerGui.buttons.Frame.home.MouseButton 1 Click:Connect( function (player) |
70 | 70 cam.CameraType = Enum.CameraType.Custom |
71 | 71 player.PlayerGui.buttons:Destroy() |
72 | 72 humanoid.WalkSpeed = 16 |
76 | 76 player.PlayerGui.buttons.Frame.front.MouseButton 1 Click:Connect( function (player) |
77 | 77 if Iterator < = 4 then |
78 | 78 Iterator = Iterator + 1 |
79 | 79 local count = tostring (Iterator) |
80 | 80 local val = "col" ..count |
81 | 81 local focus 2 = game.Workspace:WaitForChild( tostring (val)) |
82 | 82 local ts 2 = TweenInfo.new( 2 ,Enum.EasingStyle.Quad,Enum.EasingDirection.In, 0 , false , 0 ) |
83 | 83 local Goals 2 = { CFrame = focus 2. CFrame } |
84 | 84 local move 2 = tween:Create(cam,ts 2 ,Goals 2 ) |