Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How could i fix "attempt to call a nil value"?

The script is supposed to reset the camera and the controls when the gameStarted intValue is 1, there is a countdown that counts 30 seconds and once it passes the value of gameStarted is 1, but when i run the script to free the camera and the controls, i keep getting this error and the script cuts off at line 4. local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")) local Controls = PlayerModule:GetControls() local gameStarted = game.ReplicatedStorage:WaitForChild("gameStarted") script.Parent.MouseButton1Click:Connect() if gameStarted.Value == 1 then Controls:Enable() workspace.CurrentCamera.FieldOfView = 50 game.Players.LocalPlayer.CameraMode = 'LockFirstPerson' end

1 answer

✓ Accepted answer

hi, hope this work

local PlayerModule = require(game.Players.LocalPlayer.PlayerScripts:WaitForChild("PlayerModule")) 
local Controls = PlayerModule:GetControls() 
local gameStarted = game.ReplicatedStorage:WaitForChild("gameStarted") 

script.Parent.MouseButton1Click:Connect(function() 
	if gameStarted.Value == 1 then 
		Controls:Enable() workspace.CurrentCamera.FieldOfView = 50
		game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
	end
end)

4 comments

0

You need to explain what did u do to fix it, -1 for u...jk I am a nice person

0

Basically what he did it the user asking the question forgot to add local on the gameStarted variable

0

hi

0

Thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.