GetPData Issue

Anytime I run an addon using ply:GetPData I get the same error just in a different form, I can not figure out whats causing it, I’ve even ran a test script with ply:GetPData to rule some of the options out but It still persists.

Heres an example of the error:

Any ideas?

“ply” is not a valid entity. IsValid(ply) should return false if you run it on the line before ply:GetPData.




function ulx.votemute( calling_ply, target_ply, minutes )
	minutes = math.ceil(minutes)
	if voteInProgress then
	
		ULib.tsayError( calling_ply, "There is already a vote in progress. Please wait for the current one to end.", true )
		
		return
		
	end

	local msg = "Mute " .. target_ply:Nick() .. " for " .. minutes .. " minutes?"

	ulx.doVote( msg, { "Yes", "No" }, voteMuteDone, _, _, _, target_ply, minutes, calling_ply )
	
	ulx.fancyLogAdmin( calling_ply, "#A started a vote mute of #i minute(s) against #T", minutes, target_ply )
	
end
local votemute = ulx.command( "Custom", "ulx votemute", ulx.votemute, "!votemute" )
votemute:addParam{ type=ULib.cmds.PlayerArg }
votemute:addParam{ type=ULib.cmds.NumArg, min=0, default=3, hint="minutes", ULib.cmds.allowTimeString, ULib.cmds.optional }
votemute:defaultAccess( ULib.ACCESS_ALL )
votemute:help( "Starts a public vote mute against target." )
if SERVER then ulx.convar( "votemuteSuccessratio", "0.7", _, ULib.ACCESS_ADMIN ) ulx.convar( "votemuteMinvotes", "3", _, ULib.ACCESS_ADMIN ) end

timer.Create( "votemutetimer", 60, 0, function()

	for k,v in pairs( player.GetAll() ) do
	
		if ( not v or not IsValid(v) ) then return end

			if ( v:GetPData( "votemuted" ) and v:GetPData( "votemuted" ) ~= 0 and v:GetPData( "votemuted" ) ~= "0" ) then

			v:SetPData( "votemuted", tonumber( v:GetPData( "votemuted" ) ) - 1 )
					
			timer.Simple( 0.5, function()
					
				if v:GetPData( "votemuted" ) == 0 or v:GetPData( "votemuted" ) == "0" then
						
					v:RemovePData( "votemuted" )
							
					ULib.tsay( nil, v:Nick() .. " was auto-unmuted." )
							
				end
						
			end )

		end

	end

end )

function ulx.unvotemute( calling_ply, target_plys )

	for k,v in pairs( target_plys ) do
	
		if ( v:GetPData( "votemuted" ) and v:GetPData( "votemuted" ) ~= 0 and v:GetPData( "votemuted" ) ~= "0" ) then
	
			v:RemovePData( "votemuted" )
			
			ulx.fancyLogAdmin( calling_ply, "#A unmuted #T", target_plys )
			
		else
		
			ULib.tsayError( calling_ply, v:Nick() .. " is not muted." )
			
		end
		
	end
	
end
local unvotemute = ulx.command( "Custom", "ulx unvotemute", ulx.unvotemute, "!unvotemute" )
unvotemute:addParam{ type=ULib.cmds.PlayersArg }
unvotemute:defaultAccess( ULib.ACCESS_ADMIN )
unvotemute:help( "Unmute the player" )

local function ulxvotemutehook( ply )

	if ( ply:GetPData( "votemuted" ) and ply:GetPData( "votemuted" ) ~= 0 and ply:GetPData( "votemuted" ) ~= "0" ) then

		return ""
		
	end
	
end
hook.Add( "PlayerSay", "ulxvotemutedhook", ulxvotemutehook )



Heres the section it came from I don’t see anything wrong with it and why it would be invalid because it would only be called when the function is called? Unless I’m just being stupid and missing something.