This is a strange one. While testing in Studio, everything seems to be working fine, but when I join the game, a specific system does not work as intended and I get an “Attempt to index nil” error in the ingame console.
The strange part is that the system works flawlessly in Studio, yet ingame, it does not. I also had someone else test the game before and they have claimed that the problem was inconsistent; sometimes it would happen, sometimes it wouldn’t.
Here is the part of the LocalScript’s code that seems to be failing:
local players = game:GetService("Players")
local runservice = game:GetService("RunService")
local storage = game:GetService("ReplicatedStorage")
local player = players.LocalPlayer
local debounce = true
player.CharacterAdded:Connect(function(char)
local animator = char:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator")
local mouse = player:GetMouse()
local gui = player.PlayerGui:WaitForChild("Target")
local gui2 = player.PlayerGui:WaitForChild("BotAction")
I would like to know what is causing this code to fail. Again, it works perfectly in Studio testing, just not ingame.