I'm making an FNaF game on Roblox and I put two Camera Blocks and I also put a GUI button to switch Cameras but It says "Attempt To Call A Nil Value"
Here's the code:
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Camera = workspace.CurrentCamera local TurnButton = game.StarterGui.TurnGUI.TurnButton function onClick() repeat wait() Camera.CameraType = Enum.CameraType.Scriptable until Camera.CameraType == Enum.CameraType.Scriptable Camera.CFrame = workspace.CameraPOV2.CFrame end script.Parent.MouseButton1Click:connect()
Can someone please help me?
If you want the button to work use this instead, you never told the script what to do when the button was pressed. Though you made a function, the function was never fired meaning, the script has an error, due to no end.
script.Parent.MouseButton1Click:connect(onClick()