I am making a zombie shooting range game that has levels. Whenever I try to access the leaderstats level value it returns the error: Attempt to index nil with 'leaderstats'. Here is the code:
game.Workspace["Shooting range"].LevelSeven.Touched:Connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player:WaitForChild("leaderstats").Level.Value == 7 then remote3:FireClient(player) end end)
If you need anything extra just let me know.
Try using:
if player then if player:WaitForChild("leaderstats").Level.Value == 7 then remote3:FireClient(player) end end
Checking if the player actually exists, if the GetPlayerFromCharacter
function was successful