Take a look - it says the player is nil
local Players = game:GetService("Players") local player = Players.LocalPlayer while true do wait(5) print(player) if owner.Value ~= nil then if owner.Value == player then print("yay") end end end
Thanks for the Help!
The Player isn't nil
, it's simply an Object
, trying to print
such a thing will give no results, simply because there is nothing to give; thus nil
. You'll need a direct reference, such as a property or something of the sorts for it to give a viable output, for example, try printing their username:
print(Player.Name)
If this doesn't work out, and somehow the Player
is truly nil
try using this debug statement for varification or restarting ROBLOX Studio:
if (Player ~= nil) then print("accessible") else print("null") end
player is your Player object. When you call print(player)
, it prints the name of your player because the built-in print function tries to use tostring() on anything that's not already a string. For players, this returns the player name.
But... you can't compare a string that is a player name to the player object, that will not match. You have to do something like if stringValueObject.Value == player.Name then