local characters = workspace:WaitForChild("Characters"):WaitForChild("CharactersInGame"):GetChildren()
local character = nil
local root = nil
02:51:14.821 Workspace.BotSphere.Script:80: attempt to index nil with 'WaitForChild' - Server - Script:80
02:51:14.823 Stack Begin - Studio
02:51:14.823 Script 'Workspace.BotSphere.Script', Line 80 - Studio - Script:80
02:51:14.824 Stack End - Studio
I think I know what’s happening, you need to wait for the character to be loaded but I can’t really tell if you are changing the character variable or not, but this is how you get the character:
Local Script
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- code here
Server Script
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
-- code here
end)
end)