I was going to make a Spectate Function so you can see other players camera
I keep getting a error saying that it attempted to connect but failed because Passed Value is not a function. Thats not right because i already setup the functions.
Heres my code and the exception happend at line 25 and 26 Which is script.Parent.Parent.Style.Forward.MouseButton1Click:connect(GoForward)
script.Parent.Parent.Style.Back.MouseButton1Click:connect(GoBack)
script.Parent.MouseEnter:connect(function() script.Parent:TweenPosition(UDim2.new(0,0,0.3,0),"Out","Quad",0.1) script.Parent.Parent.Parent.MouseOver:Play() end) script.Parent.MouseLeave:connect(function() script.Parent:TweenPosition(UDim2.new(0,-20,0.3,0),"Out","Quad",0.1) end) players = {} PChoice = 1 script.Parent.MouseButton1Click:connect(function() Spectating = false script.Parent.Parent.Parent.MouseClick:Play() if script.Parent.Selected == false then script.Parent.Selected = true script.Parent.Parent.Style.Visible = true for i,v in ipairs(Game.Players:GetChildren()) do if v.Name ~= game.Players.LocalPlayer.Name then table.insert(players,v) end end script.Parent.Parent.Style.Forward.MouseButton1Click:connect(GoForward) script.Parent.Parent.Style.Back.MouseButton1Click:connect(GoBack) else script.Parent.Selected = false script.Parent.Parent.Style.Visible = false game.Workspace.CurrentCamera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid end end) while true do if game.Players.NumPlayers == 1 then script.Parent:TweenPosition(UDim2.new(0,-150,0.3, 0),"In","Quad",0.5) else script.Parent:TweenPosition(UDim2.new(0,-15,0.3, 0),"Out","Quad",0.5) end wait() end function GoForward() PChoice = PChoice + 1 if PChoice >= #players then PChoice = 1 end game.Workspace.CurrentCamera.CameraSubject = players[PChoice].Character.Humanoid end function GoBack() PChoice = PChoice - 1 if PChoice <= 1 then PChoice = #players end game.Workspace.CurrentCamera.CameraSubject = players[PChoice].Character.Humanoid end
Heres the error i got
10:28:27.170 - Attempt to connect failed: Passed value is not a function
10:28:27.170 - Script 'Players.Player2.PlayerGui.Spectate.Button.System', Line 25
10:28:27.170 - Stack End
10:28:27.170 - Attempt to connect failed: Passed value is not a function
10:28:27.170 - Script 'Players.Player2.PlayerGui.Spectate.Button.System', Line 26
10:28:27.170 - Stack End
I'm not sure, but I think the functions these lines connect are below, but they need to be above the codeblock.