Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Attempt To Call A Nil Value?

Asked by 3 years ago

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?

0
Is it a localscript? sayer80 457 — 3y
0
Yes it is YoungsterJeremy1 6 — 3y
0
I put it in the guibutton YoungsterJeremy1 6 — 3y
0
The way to access a gui should be though script.Parent then blah blah or player:WaitForChild("PlayerGui") then your info, StarerGui is where the base guis are but the guis a player sees is replicated into a folder in the player called PlayerGui FirezDevv 162 — 3y

1 answer

Log in to vote
0
Answered by
FirezDevv 162
3 years ago

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()

0
There's a syntax error could you possibly put in the whole script in? Just to make sure YoungsterJeremy1 6 — 3y
0
Sorry I fixed it you you don't put do script.Parent.MouseButton1Click:connect(onClick() you do ,script.Parent.MouseButton1Click:connect(onClick) YoungsterJeremy1 6 — 3y
0
:Connect()* Ziffixture 6913 — 3y
0
You should also mention how TurnButton is referenced incorrectly and how they'll experience replication issues. Ziffixture 6913 — 3y
Ad

Answer this question