game.Players returning nil

hiii so this is my script but it returns nil even tho everything is correctly set up :confused: in indexes nil when trying to access the player

local player = script.Parent.player.Value
local players = game:GetService("Players")
local playerName = players:FindFirstChild(player)

print(playerName)
print(players:FindFirstChild(player).AbilitiesLength.FireBall.Value)

for i = 1, players:FindFirstChild(player).AbilitiesLength.FireBall.Value + 1, 1 do
	if i ==  players:FindFirstChild(player).AbilitiesLength.FireBall.Value then
		script.Parent:Destroy()
	end
	task.wait(1)
	print(i)
end

at line 3 it returns nil and ive tried as well game.Players:FindFirstChild(player). In the game whilst its running i go and see and my username is in the varibal script.Parent.player.Value and i even tried to do local player = “WedferCommited911” aka my username still returns nil

Change

local playerName = players:FindFirstChild(player)

to

local playerName = players:WaitForChild(player)

You are most likely experiencing an issue with the loading times.

thanks the problem was that the first varibal was empty but thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.